| View previous topic :: View next topic |
| Author |
Message |
Skyrimfus Cheater
Reputation: 1
Joined: 17 Mar 2016 Posts: 43
|
Posted: Mon Jan 25, 2021 2:17 pm Post subject: Popup menu OnClick get button |
|
|
A popup menu item can be clicked by both left mouse and right mouse buttons.
How can I detect which button was responsible for clicking the item?
I want to call different functions based on what the user clicked
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4714
|
Posted: Mon Jan 25, 2021 4:57 pm Post subject: |
|
|
I don't know if the Windows API even exposes that information.
Maybe test which mouse button is down when the callback starts.
| Code: | function menuitem_onclick(...)
if isKeyPressed(VK_LBUTTON) then
-- ...
elseif isKeyPressed(VK_RBUTTON) then
-- ...
else
-- something else or user released too quickly; safe bet is do nothing
end
end |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Skyrimfus Cheater
Reputation: 1
Joined: 17 Mar 2016 Posts: 43
|
Posted: Mon Jan 25, 2021 6:12 pm Post subject: |
|
|
| tried this doesn't work as the you have to release the button to click it so isKeyPressed will never return true
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25824 Location: The netherlands
|
Posted: Tue Jan 26, 2021 5:47 am Post subject: |
|
|
Not possible with the windows api
but you can always implement your own popupmenu. Give the object a mousedown event. Then if it's a rightclick create a new form at the position of the control or mouse, and make it's items respond to mouseover like a popupmenu does, and a mousedown where you can see if it's a left or right click
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Skyrimfus Cheater
Reputation: 1
Joined: 17 Mar 2016 Posts: 43
|
Posted: Tue Jan 26, 2021 2:06 pm Post subject: |
|
|
Ah, that would be a chore, since i'm just modifying the disassembler's popup menu. How hard would it be for you to implement so that CE passes the mouse clicked? Something like:
| Code: |
MenuItem.OnClick = function(sender,mouseButton)
|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25824 Location: The netherlands
|
Posted: Tue Jan 26, 2021 3:38 pm Post subject: |
|
|
That's not possible to do without breaking too many things
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|