Jump to content

creating window at cursor position problem


bradio10

Recommended Posts

Hi,

I am trying to make a window appear when I right click on the screen at the position of the cursor.

When I right click, it always gets created at the top left corner of the screen every time.

No errors in the debug

Code:

function drawSomethingAtCursor() 
    local x, y = getCursorPosition() 
  
    guiCreateWindow(x, y, 50, 50, "Yes?", false) 
end 
bindKey("mouse2", "down", drawSomethingAtCursor) 

Link to comment
'getCursorPosition' returns a value between 0 and 1. Do some math to make it absolute in pixels.

ok thanks.

I was able to fix the issue and it works fine now.

If anybody is wondering, I multiplied the x, y with guiGetScreenSize

here is my end code result:

 local sX, sY = guiGetScreenSize() 
  
function drawSomethingAtCursor() 
    local x, y = getCursorPosition() 
    newX, newY = x * sX, y * sY 
    win = guiCreateWindow(newX, newY, 50, 50, "Yes?", false) 
end 
bindKey("mouse2", "down", drawSomethingAtCursor) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...