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 


CE bug? Tracker bar and OnClick event. (Solved)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 3:31 pm    Post subject: CE bug? Tracker bar and OnClick event. (Solved) Reply with quote

This issue is related to track bar and the OnClick event.
Please take a look at the screenshot.
1. Say, if the "marker arrow" (you know what I mean Smile) on the track bar is at "0".
2. I click the "marker arrow" and hold down mouse 1, and then move the "marker arrow" to 5, but DO NOT RELEASE MOUSE 1.
3. While still holding down mouse 1, move the mouse cursor to somewhere else, NOT ON THE TRACK BAR.
4. Now release mouse 1, the OnClick event will not be triggered.

I am using the track bar position to calculate a variable, and I found out this issue when I was trying to move "marker arrow" from the middle of the track bar to either "0" or "15". Because of the fast motion of the mouse movement, the mouse cursor often will not stay on the "marker arrow" when I release mouse 1, so the OnClick event is not triggered. Now, in order to counter that, I can only use mouse leave event, but it's not very ideal. Every time the mouse cursor hovers over the track bar and moves away, the mouse leave event is triggered.



Capture.JPG
 Description:
 Filesize:  10.39 KB
 Viewed:  6751 Time(s)

Capture.JPG




Last edited by Dr.Disrespect on Thu May 12, 2016 6:41 pm; edited 2 times in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4691

PostPosted: Thu May 12, 2016 3:52 pm    Post subject: Reply with quote

That's because the OnClick event triggers only if you click on something. I wouldn't call that a bug.
Use the OnChange event instead. If you need it to take effect only when you release the mouse, use isKeyPressed(VK_LBUTTON).

_________________
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
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu May 12, 2016 4:00 pm    Post subject: Reply with quote

That's how things work. You can cancel mouse click that way.
(hold down mouse 1 on any button, move outside, release it. Try it in other applications)


PS: you can use OnMouseUp event (if you don't like OnChange behaviour)

_________________
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 4:07 pm    Post subject: Reply with quote

@Penguin,
The OnChange event gets triggered every time when the value changes, so if I move the marker from 15 to 1, the event will be triggered 14 times, which is not that good. The "isKeyPressed()" function is good, but how to relate it to my situation? Do I need a timer to constantly check it?

@mgr.inz.Player,
Thanks for the reply. I will try Penguin's method when I figure out how to use isKeyPressed().

Edit:
Oh, I didn't see your "PS", mgr.inz.Player. But the OnMouseUp event has four parameters, what does the "button" and "x", "y" mean?


Last edited by Dr.Disrespect on Thu May 12, 2016 4:18 pm; edited 2 times in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4691

PostPosted: Thu May 12, 2016 4:09 pm    Post subject: Reply with quote

Wrap the contents of the OnChange function inside an if statement checking whether or not the left mouse button is held down.
_________________
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
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 4:23 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Wrap the contents of the OnChange function inside an if statement checking whether or not the left mouse button is held down.


Do you mean something like this:
Code:


if isKeyPressed(VK_LBUTTON) then
   do something
else
   do something else
end



But I still need something to call this "if" statement, right? I am kinda lost.... sorry.

@mgr.inz.Player
Can you explain the "button", "x" and "y" parameters in the OnMouseUp event? Thanks.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4691

PostPosted: Thu May 12, 2016 4:26 pm    Post subject: Reply with quote

Code:
function CETrackBar1Change(sender)
  if not isKeyPressed(VK_LBUTTON) then
    -- code
  end
end

Alternatively, I realized you could also do it this way:
Code:
function CETrackBar1Change(sender)
  if isKeyPressed(VK_LBUTTON) then return end
  -- code
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
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 4:28 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
function CETrackBar1Change(sender)
  if not isKeyPressed(VK_LBUTTON) then
    -- code
  end
end

Alternatively, I realized you could also do it this way:
Code:
function CETrackBar1Change(sender)
  if isKeyPressed(VK_LBUTTON) then return end
  -- code
end


Oh! You are so smart. Very Happy GOt your point! Thanks again.

Edit:
The code still got called 2 to 3 times after I released mouse 1, which I can't figure out why. I think I will just let it be.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu May 12, 2016 4:48 pm    Post subject: Reply with quote

fmanager wrote:
@mgr.inz.Player
Can you explain the "button", "x" and "y" parameters in the OnMouseUp event? Thanks.


button - which mouse button
x and y - cursor position


you can ignore those, just use sender.Position

_________________
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 4:55 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
fmanager wrote:
@mgr.inz.Player
Can you explain the "button", "x" and "y" parameters in the OnMouseUp event? Thanks.


button - which mouse button
x and y - cursor position


you can ignore those, just use sender.Position


Thanks, mgr.inz.Player. I will just use (VK_LBUTTON), but with regard to x,y, is it sender.Position.x and sender.Position.y?

Edit:
Strangely, the following works perfectly:
Code:

function CETrackBar1MouseUp(sender, VK_LBUTTON, Position)
  showMessage(tostring(UDF1.CETrackbar1.Position))
end


Just did a little test, this also works:
Code:

function CETrackBar1MouseUp(sender, VK_LBUTTON)
  showMessage(tostring(UDF1.CETrackbar1.Position))
end


It looks like "x,y" can be ignored entirely. Very Happy
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu May 12, 2016 5:41 pm    Post subject: Reply with quote

VK_LBUTTON variable as function parameter? You are messing many things Shocked

Just use
Code:
function CETrackBar1MouseUp(sender, button, x, y)
  showMessage(tostring(sender.Position))
end



Lua is smart, so you can use this function too:
Code:
function CETrackBar1MouseUp(sender)
  showMessage(tostring(sender.Position))
end

_________________
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu May 12, 2016 6:39 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
VK_LBUTTON variable as function parameter? You are messing many things Shocked

Just use
Code:
function CETrackBar1MouseUp(sender, button, x, y)
  showMessage(tostring(sender.Position))
end



Lua is smart, so you can use this function too:
Code:
function CETrackBar1MouseUp(sender)
  showMessage(tostring(sender.Position))
end


Thanks, mgr.inz.Player. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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