Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Popup menu OnClick get button

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 43

PostPosted: Mon Jan 25, 2021 2:17 pm    Post subject: Popup menu OnClick get button Reply with quote

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
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4714

PostPosted: Mon Jan 25, 2021 4:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 43

PostPosted: Mon Jan 25, 2021 6:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25824
Location: The netherlands

PostPosted: Tue Jan 26, 2021 5:47 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Skyrimfus
Cheater
Reputation: 1

Joined: 17 Mar 2016
Posts: 43

PostPosted: Tue Jan 26, 2021 2:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25824
Location: The netherlands

PostPosted: Tue Jan 26, 2021 3:38 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites