java – LibGDX Change mouse cursor to custom image……and keep it there

I’m able to create a custom cursor no problem using the following code running in my GameScreen’s Show method:

Pixmap pixmap = new Pixmap(Gdx.files.internal("ui/cursor.png"));
Cursor cursor = Gdx.graphics.newCursor(pixmap, pixmap.getWidth() / 2, pixmap.getHeight() / 2);
Gdx.graphics.setCursor(cursor);
pixmap.dispose();

The problem is…if I deselect the game window and return back…the cursor has returned back to the default one. At least that happens for me on Mac desktop. If I move the cursor out of the screen (without deselecting) and then back again I get the custom cursor image back but I don’t think people would know to do that.

But after searching I couldn’t find any way for LibGDX to detect when the game window is deselected? I thought I would be able to find that since it would seem useful for something like automatically pausing when deselecting the game window and such.

That would seem to be the way to reset the cursor every time returning to the game window, unless there’s some other way to make it more permanent?

Excel Chart – Crosshair cursor lines with VBA

Submitting for expert review. Refer YouTube video

Paste this code in excel VBE Chart(Sheet) object.

Code works fine. I was wondering if we can avoid deletion and addition of lines with every mouse move. I tried adding lines on chart activate event and then allign those lines using module level variables. But the too procedures cannot work together as by the time chart activate is triggered mouse move already takes place.

Option Explicit

Private xPoint As Variant, yPoint As Variant, XMax As Variant, YMax As Variant, DispScale As Variant
Private shp As Shape, ChartPaperSize, PgWidPXL, PgHgtPXL, ChtAreaWid, ChtAreaHgt, ActWinZoom
Private shpHL As Variant, shpVL As Variant

'--------------------------------------------------------------------------------
Private Sub Chart_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal A As Long, ByVal B As Long)
'Dim xPoint As Variant, yPoint As Variant, XMax As Variant, YMax As Variant, DispScale As Variant
'Dim shp As Shape, ChartPaperSize, PgWidPXL, PgHgtPXL, ChtAreaWid, ChtAreaHgt, ActWinZoom
'This macro is suitable for following 4 paper sizes only
'--------------------------------------------------------------------------------
ChartPaperSize = ActiveChart.PageSetup.PaperSize
Select Case ChartPaperSize
' I couldnt find better way to convert paper size number to inches and therafter to pixels
' I dont know why multiplying by 0.9745 or 0.9725 keeps the x, y coordinates more close to the diplayed cursor position
    Case 5 '"xlPaperLegal"
       If ActiveChart.PageSetup.Orientation = xlLandscape Then
       PgWidPXL = 14 * 220 * 0.9745 '220 PPI
       PgHgtPXL = 8.5 * 220 * 0.9725
       Else
       PgWidPXL = 8.5 * 220 * 0.9745
       PgHgtPXL = 14 * 220 * 0.9725
       End If
    Case 1 '"xlPaperLetter"
       If ActiveChart.PageSetup.Orientation = xlLandscape Then
       PgWidPXL = 11 * 220 * 0.9745
       PgHgtPXL = 8.5 * 220 * 0.9725
       Else
       PgWidPXL = 8.5 * 220 * 0.9745
       PgHgtPXL = 11 * 220 * 0.9725
       End If
    Case 9 '"xlPaperA4"
       If ActiveChart.PageSetup.Orientation = xlLandscape Then
       PgWidPXL = 11.69 * 220 * 0.9745
       PgHgtPXL = 8.27 * 220 * 0.9725
       Else
       PgWidPXL = 8.27 * 220 * 0.9745
       PgHgtPXL = 11.69 * 220 * 0.9725
       End If
    Case 8 ' "xlPaperA3"
       If ActiveChart.PageSetup.Orientation = xlLandscape Then
       PgWidPXL = 16.54 * 220 * 0.9745
       PgHgtPXL = 11.69 * 220 * 0.9725
       Else
       PgWidPXL = 11.69 * 220 * 0.9745
       PgHgtPXL = 16.54 * 220 * 0.9725
       End If
    'Case Else
End Select

'Windows display recommended scale of 125% in my computer settings
XMax = PgWidPXL * (100 / 125) ' for A4 2503 for legal 2999 '2395 'Max mousepointer width on 100% chart sheet zoom
YMax = PgHgtPXL * (100 / 125) ' for A4 1764 for legal 1814 '1450 'Max mousepointer height on 100% chart sheet zoom

ChtAreaWid = ChartArea.Width
ChtAreaHgt = ChartArea.Height

DispScale = Round(1161 / ActiveWindow.Width, 2)
' 1161 is ActiveWindow.Width at Windows display recommended scale of 125% on my computer

ActWinZoom = ActiveWindow.Zoom
xPoint = (A * (ChtAreaWid * DispScale) / XMax) / (ActWinZoom / 100)
yPoint = (B * (ChtAreaHgt * DispScale) / YMax) / (ActWinZoom / 100)
'--------------------------------------------------------------------------------
'Delete lines
For Each shp In ActiveChart.Shapes
If shp.Type = msoLine Then
shp.Delete
End If
Next

'Add new lines
With ActiveChart.Shapes.AddLine(1, yPoint, ChartArea.Width, yPoint).Line  'horizontal line
.ForeColor.RGB = RGB(150, 150, 150)
.Weight = 5
End With
With ActiveChart.Shapes.AddLine(xPoint, 1, xPoint, ChartArea.Height).Line  'vertical line
.ForeColor.RGB = RGB(150, 150, 150)
.Weight = 5
End With
'--------------------------------------------------------------------------------
'Above deletion and addition of new lines could be avoided if two lines are already present
'Say, we manually insert line shapes named "Straight Connector 1" and "Straight Connector 2" then

'With ActiveChart.Shapes("Straight Connector 1") 'horizontal line
'.Left = 1
'.Top = yPoint
'.Width = ChartArea.Width
'.Height = yPoint
'End With
'With ActiveChart.Shapes("Straight Connector 2") 'vertical line
'.Left = xPoint
'.Top = 1
'.Width = xPoint
'.Height = ChartArea.Height
'End With
'--------------------------------------------------------------------------------

End Sub

kubuntu – Show a hidden latte-dock by hovering cursor over it

I have recently switched from GNOME to KDE. I had previously used the DashtoDock GNOME extension, and am now using Latte to achieve the same on KDE. As far as I’ve read, it’s the recommended dock to use with Plasma.

One thing I’m hitting a snag with is “showing” a hidden dock. For example when I have behaviour set to auto-hide, I cannot find any way to reveal the dock. For Dodge-Maximised etc the only solution I have found is to set a keyboard shortcut. I can live with that if I have to, but is there no way to make it show when moving the cursor to the edge of the screen?

I am using Kubuntu 20.04 LTS, and have Plasma 5.18.5.

Thanks in advance!

How do i Make the windows mouse cursor speed the same as in macOS

I’ve Googled a Bit But Couldn’t Find the Answer
I think I also need to adjust acceleration too

mac – Jittery macOS mouse cursor when hovering over links

I’m experiencing a jittery/buggy mouse cursor when moving my mouse over hyperlinks.

Every time the mouse transitions from the hyperlink pointer to the arrow pointer, the arrow pointer briefly visibly flashes in the wrong position before correcting itself.

This is in macOS 10.15 Catalina on my new 16″ MacBook Pro, provided by work and with a variety of software installed. On other computers running 10.14 and 10.15 I am not experiencing the problem.


Reproduction steps:

  1. Hover mouse above a hyperlink. (Shows “Mickey Mouse glove” pointer.)
  2. Move mouse pointer off the hyperlink so that cursor changes to the arrow pointer.
  3. Arrow pointer initially flashes at the “top left” position of the mouse bounding box for 1 frame.
  4. Arrow pointer then flashes back to its true position, pointing at the same pixels that the hyperlink glove was originally pointing.

When I create a screen recording via QuickTime, the mouse glitch is not visible in the recording.

Here is an iPhone video of Mac’s screen demonstrating this issue:

gif of this problem in action


This is driving me nuts. On link-heavy pages, moving the mouse across the screen results in a dizzying blur of pointer motion. Middle-clicking a link also produces a similar jitter.

The problem remains after Restart.

stored procedures – MySQL – Pass input parameter into Cursor query

Is it possible to pass input parameter into Cursor

SELECT statement WHERE clause?

For some reason I think it isn’t working.

I’m trying to pass _TAG and _ITEM_NAME into where clause.

    DECLARE cursor_test cursor 
for SELECT itemid  
FROM items 
WHERE  key_ LIKE "sometext_@_TAG_sometext_@_ITEM_NAME" 
AND STATUS = '0';

Here is the the Stored procedure:

    DELIMITER //
    CREATE PROCEDURE getSomething(IN _HOSTNAME VARCHAR(20), 
                                  _TAG VARCHAR(20), 
                                  _ITEM_NAME VARCHAR(50))
    BEGIN
    declare FINISHED BOOL default false;

    DECLARE cursor_test cursor for SELECT itemid  
FROM items 
WHERE hostid = @_HOSTID AND key_ 
LIKE "sometext_@_TAG_sometext_@_ITEM_NAME" 
AND STATUS = '0';

    DECLARE CONTINUE HANDLER for not found set FINISHED := true;

    SET @HOSTNAME = _HOSTNAME;

    PREPARE STMT1 FROM

    "SELECT hostid INTO @_HOSTID FROM hosts  WHERE NAME = ?";

    EXECUTE STMT1 USING @HOSTNAME;
    DEALLOCATE PREPARE STMT1;

    open cursor_test;
       SET @TOTAL_VALUE := 0;
       loop_itemid: loop
            fetch cursor_test into _ITEMID;
            SELECT _ITEMID;
            if FINISHED then
                leave loop_itemid;
            end if;
            SET @TOTAL_VALUE := @TOTAL_VALUE + 
             (SELECT value from history_uint WHERE itemid = _ITEMID 
               ORDER BY clock DESC LIMIT 1);

       end loop loop_itemid;
       SELECT @TOTAL_VALUE;
    close cursor_test;

    END //

How can MS Word 2013 still remember my last cursor point?

I really amazed how can MS Word 2013 still remember my last cursor point ?

I deleted the document but I downloaded the document from my email inbox still it remembers where I left off.

enter image description here

I know Vlc used to have this feature but forgot after system reboot but MS word remembers even after reboot.

unity – Setting up a shader for RTS construction grid visibility (around cursor)

I’ve set up a shader, thanks to the good help of @DMGregory over at : Draw animating grid with terrain deformation and variable colors

here’s what I got so far :

messed up shader

here’s what it’s supposed to look like :

desired result shader

here’s what my shader code looks like as it stands :

full current shader

forgive my non-2K + screen it’s only a 1080p but this is the full shader.

here’s each bit in isolation :

image1

image2

image3

image4

image5

here’s the main options for the node :

settings

If I set surface to transparent…

I get a much better result :

shader test

yet still not what I want because the grid area fades out immediately instead of staying at the center of the cube :

result

also the corner clearly has a green and red line overlap when line should only ever be red or green.

this is the mock file that I’m currently using for buildable and non buildable area :

mock buildable texture

it’s 256×256 (the size of my map) for now because I want to start small (where 1px maps to one unity square on the terrain of 1 unit) before I move on to the real deal which should be a 3584×3584 Texture 2D (where 1px corresponds to 1/14th of a unity unit).

I want my grid to be 1/14th of an digit. eg cell one is from (0.0f, 0.0f) to (0.14f, 0.14f).

I’ve got preliminary code which will serve to generate this texture 2D programmatically :

    editable2DconstructibleMap = new Texture2D(256, 256, TextureFormat.RGBA32, false);
    constructionGrid = GameObject.FindGameObjectWithTag("GridViewer").GetComponent<MeshRenderer>();

    // fill texture color corresponding to navMesh
    for (int x = 0; x < editable2DconstructibleMap.width; x++) {
        for (int y = 0; y < editable2DconstructibleMap.height; y++) {
            NavMeshHit hit;
            if (NavMesh.SamplePosition(new Vector3(x * 1.0f, 0f,y * 1.0f), out hit, 1.0f, NavMesh.AllAreas))
            {
                editable2DconstructibleMap.SetPixel(x, y, Color.white);
            }
            else
            {
                editable2DconstructibleMap.SetPixel(x, y, Color.black);
            }
        }
    }
    constructionGrid.sharedMaterial.SetTexture("BuildableMask", editable2DconstructibleMap);

Here I’m using the navMesh which itself is automatically generated based on terrain slope.

I target each point of the map and see if it falls in or out of the navmesh.

Instead of redrawing this texture 2D when a building is placed and placement becomes impossible. I think I’ll simply programmatically edit the 2D texture to add the new black pixels whilst the navmesh will be updated independently.
Anyways, I guess the green + red overlap issue comes from my texture2D being currently too small, but if I don’t know yet what one pixel corresponds to, I’ll have trouble getting this right.

cursor – Procedimiento con cursores Oracle

Tengo este procedimiento hecho, pero en un departamento no hay empleados y quiero que dentro de ese departamento me muestre un mensaje, y no logro conseguirlo. Lo he probando haciendo un IF y tambien con una EXCEPTION pero no logro hacerlo.

CREATE OR REPLACE PROCEDURE infodept
AS
CURSOR dept IS SELECT dept_num,dept_nom from dept;
vdept dept%ROWTYPE;
CURSOR empl IS SELECT empl_num,empl_nom,empl_ofici from empl where empl_dept_num=vdept.dept_num;
vempl empl%ROWTYPE;
BEGIN
OPEN dept;
    FETCH dept INTO vdept;
    WHILE dept%FOUND LOOP
    DBMS_OUTPUT.PUT_LINE(vdept.dept_num||' - '|| vdept.dept_nom);
        OPEN empl;
                FETCH empl INTO vempl;
                WHILE empl%FOUND LOOP
                DBMS_OUTPUT.PUT_LINE('        '||vempl.empl_num||' - '||vempl.empl_nom||' - '||vempl.empl_ofici);
                FETCH empl INTO vempl;
                END LOOP;
        CLOSE empl;
    FETCH dept INTO vdept;
    END LOOP;
CLOSE dept;
END;

Este seria el resultado de mi codigo, como veis, debajo del ultimo departamento no me muestra nada, ahi quiero que salga: ‘Este departamento no tiene empleados.’

introducir la descripción de la imagen aquí

Techniques to adjust the cursor to the vertex in WebGL or OpenGL?

What is a technique to snap the mouse pointer to vertices in WebGL or OpenGL?