View previous topic :: View next topic |
Author |
Message |
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 04, 2022 11:03 am Post subject: Equivalent for OnClickRelease? |
|
|
Is there some equivalent for OnClickRelease=?
For example, I need to be able to do this:
Code: | OnClick=DoSomething
OnClickRelease=Close |
If I add OnClick=Close, then the OnClick=DoSomething does not happen because the window closes.
Looking through celua.txt, I cannot find any solution for this. I have also searched the web and have tried many different things without success.
Thanks.
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Feb 04, 2022 11:29 am Post subject: |
|
|
It's a little janky but you can achieve that with a custom function:
Code: |
function OnClickRelease()
// 0x01 = Left Mouse Button
if not isKeyPressed(0x01) then
print('released')
end
end
|
In the onClick event just call this function at the end.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25570 Location: The netherlands
|
Posted: Fri Feb 04, 2022 11:49 am Post subject: |
|
|
OnMouseDown=dosomething
OnMouseUp=Close
_________________
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 |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Feb 04, 2022 11:56 am Post subject: |
|
|
Dark Byte wrote: | OnMouseDown=dosomething
OnMouseUp=Close |
That will only work if there are controls involved, correct?
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 04, 2022 12:07 pm Post subject: |
|
|
Thank you, guys. I really appreciate the help.
Sorry, DB, I did not want to keep bothering you with this. I am just trying to alter the script that you gave me earlier. While I have a few things sorted, I could not figure this one out.
Code: | --handy helper function
function forEachAndFutureForm(classname, func)
local i
for i=0,getFormCount()-1 do
local f
f=getForm(i)
if f.ClassName==classname then
func(f)
end
end
registerFormAddNotification(function(f)
if classname==f.ClassName then
f.registerFirstShowCallback(function()
func(f)
end)
end
end)
end
forEachAndFutureForm('TfrmAutoInject',function(f)
b=createButton(f)
b.Caption='Add to Table'
b.OnClick=f.Assigntocurrentcheattable1.OnClick
b.parent=f.Panel3
b.SetHeight(30)
b.SetWidth(130)
b.AutoSize=false
b.AnchorSideLeft.Control=f.btnExecute
b.AnchorSideLeft.Side=asrRight
b.AnchorSideTop.Control=f.btnExecute
b.AnchorSideTop.Side=asrTop
end) |
I tried both suggestions, but could not get them to work. I am too stupid to implement LeFiXER's code, and the MouseUp solution probably does not work in this case without changing more.
Thanks.
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Feb 04, 2022 12:22 pm Post subject: |
|
|
++METHOS wrote: |
...
I tried both suggestions, but could not get them to work. I am too stupid to implement LeFiXER's code, and the MouseUp solution probably does not work in this case without changing more.
Thanks. |
No need to apologise. Just trying to help where I can. Providing the code gives a little more context for me so thank you, with this you can actually do it like DB mentioned:
Code: |
--handy helper function
function forEachAndFutureForm(classname, func)
local i
for i=0,getFormCount()-1 do
local f
f=getForm(i)
if f.ClassName==classname then
func(f)
end
end
registerFormAddNotification(function(f)
if classname==f.ClassName then
f.registerFirstShowCallback(function()
func(f)
end)
end
end)
end
forEachAndFutureForm('TfrmAutoInject',function(f)
b=createButton(f)
b.Caption='Add to Table'
--b.OnClick=f.Assigntocurrentcheattable1.OnClick
--
b.OnMouseDown=f.Assigntocurrentcheattable1.OnClick
b.OnMouseUp=myfunction() -- whatever function you want to execute on mouseup
--
b.parent=f.Panel3
b.SetHeight(30)
b.SetWidth(130)
b.AutoSize=false
b.AnchorSideLeft.Control=f.btnExecute
b.AnchorSideLeft.Side=asrRight
b.AnchorSideTop.Control=f.btnExecute
b.AnchorSideTop.Side=asrTop
end)
|
As for which events you can use for the button control, you have:
OnChange
OnClick
OnEnter
OnExit
OnMouseDown
OnMouseUp
OnMouseLeave
OnMouseMove
OnMouseUp
OnMouseWheel
OnMouseWheelDown
OnMouseWheelUp
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 04, 2022 12:41 pm Post subject: |
|
|
Thank you very much.
Sorry that it took so long to reply, but I could not get the OnMouseDown to work as intended, no matter what I tried.
This works, though:
Code: | --handy helper function
function forEachAndFutureForm(classname, func)
local i
for i=0,getFormCount()-1 do
local f
f=getForm(i)
if f.ClassName==classname then
func(f)
end
end
registerFormAddNotification(function(f)
if classname==f.ClassName then
f.registerFirstShowCallback(function()
func(f)
end)
end
end)
end
forEachAndFutureForm('TfrmAutoInject',function(f)
b=createButton(f)
b.Caption='Add to Table'
b.OnClick=f.Assigntocurrentcheattable1.OnClick
b.OnMouseUp=f.Close
b.parent=f.Panel3
b.SetHeight(30)
b.SetWidth(130)
b.AutoSize=false
b.AnchorSideLeft.Control=f.btnExecute
b.AnchorSideLeft.Side=asrRight
b.AnchorSideTop.Control=f.btnExecute
b.AnchorSideTop.Side=asrTop
end) |
Thanks, again.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Fri Feb 04, 2022 1:05 pm Post subject: |
|
|
++METHOS wrote: |
but I could not get the OnMouseDown to work as intended, no matter what I tried.
|
I guess "OnMouseDown" runs before "OnClick" and prevents "OnClick" from reaching function pressure.
My recommendation; Use "OnMouseWheel".
Like:
Code: | b.OnMouseWheelUp=function() print("hello") end
b.OnMouseWheelDown=function() print("CE") end |
EDIT:
If the mouse wheel moves more than once, the function it triggers will be continuous.
I added "Permission" to avoid this.
Code: | b.OnMouseLeave=function() permission=1 end
b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end |
and
Code: | local permission=1
forEachAndFutureForm('TfrmAutoInject',function(f)
b=createButton(f)
b.Caption='Add to Table'
b.OnClick=f.Assigntocurrentcheattable1.OnClick
b.OnMouseUp=f.Close
b.parent=f.Panel3
b.SetHeight(30)
b.SetWidth(130)
b.AutoSize=false
b.OnMouseLeave=function() permission=1 end
b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end
b.AnchorSideLeft.Control=f.btnExecute
b.AnchorSideLeft.Side=asrRight
b.AnchorSideTop.Control=f.btnExecute
b.AnchorSideTop.Side=asrTop
end) |
_________________
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Feb 04, 2022 1:39 pm Post subject: |
|
|
AylinCE wrote: |
I guess "OnMouseDown" runs before "OnClick" and prevents "OnClick" from reaching function pressure.
My recommendation; Use "OnMouseWheel".
Like:
Code: | b.OnMouseWheelUp=function() print("hello") end
b.OnMouseWheelDown=function() print("CE") end |
EDIT:
If the mouse wheel moves more than once, the function it triggers will be continuous.
I added "Permission" to avoid this.
Code: | b.OnMouseLeave=function() permission=1 end
b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end |
and
Code: | local permission=1
forEachAndFutureForm('TfrmAutoInject',function(f)
b=createButton(f)
b.Caption='Add to Table'
b.OnClick=f.Assigntocurrentcheattable1.OnClick
b.OnMouseUp=f.Close
b.parent=f.Panel3
b.SetHeight(30)
b.SetWidth(130)
b.AutoSize=false
b.OnMouseLeave=function() permission=1 end
b.OnMouseWheelUp=function() if permission==1 then print("hello") permission=2 end end
b.OnMouseWheelDown=function() if permission==1 then print("CE") permission=2 end end
b.AnchorSideLeft.Control=f.btnExecute
b.AnchorSideLeft.Side=asrRight
b.AnchorSideTop.Control=f.btnExecute
b.AnchorSideTop.Side=asrTop
end)
|
|
With all due respect, not only does ++METHOS have a working solution, you are misconstruing MouseDown i.e. the event triggered when state of the mouse button is in the down position, for the MouseWheel.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Fri Feb 04, 2022 2:01 pm Post subject: |
|
|
It is not my intention to undermine the solution.
++METHOS wrote: |
but I could not get the OnMouseDown to work as intended, no matter what I tried.
|
It was just to offer different idea to the comment above.
Solutions are a separate case, ideas are rich in use and archival value.
respects.
_________________
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Feb 04, 2022 2:10 pm Post subject: |
|
|
AylinCE wrote: | It is not my intention to undermine the solution.
++METHOS wrote: |
but I could not get the OnMouseDown to work as intended, no matter what I tried.
|
It was just to offer different idea to the comment above.
Solutions are a separate case, ideas are rich in use and archival value.
respects. |
Of course, I agree it's best to have multiple solutions to the same problem. No hard feelings from the comments .
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 04, 2022 2:18 pm Post subject: |
|
|
AylinCE wrote: | My recommendation; Use "OnMouseWheel". | -Thank you for your help and for your suggestion. It is always good to share ideas. Even if I do not use this method now, it could prove useful to someone that reads this later.
|
|
Back to top |
|
|
|