Jump to content
Sign in to follow this  
vrocco

Why not use OnEvent code?

Recommended Posts

vrocco

Can one of you gurus explain to me why it seems hardly anyone uses the OnEvent code when writing GUI scripts?

To me it seems much easier to make something happen when a button is clicked than to constantly monitor the program state for something to happen. I understand doing this if you have no GUI.

Please understand, I am not knocking anyone's code. I am a n00b. I simply want to learn if I could be doing things better by not making all my code "OnEvent"

Thanks in advance for the explaination!

Vito

Share this post


Link to post
Share on other sites
big_daddy

I personally prefer OnEvent over loops.

Share this post


Link to post
Share on other sites
Valuater

I found at times when working with more than two GUI's on event can create problems. While loops ( as in more than one ) can be controlled to listen for specific messages

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
FreeFry

I found at times when working with more than two GUI's on event can create problems. While loops ( as in more than one ) can be controlled to listen for specific messages

8)

Yeah, I agree with this, though imo. OnEvent mode is so much easier I'd almost always use it, even if I would have two GUI's :rolleyes:

Share this post


Link to post
Share on other sites
PsaltyDS

I prefer OnEventMode, too. All my older scripts that were coded with GuiGetMsg() loops are (slooowwly) being updated to use OnEventMode.

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Zacharot

OnEvent is technically a 'better' way to handle many things, but I've found that it requires more code to determine the state of the program. I wouldnt want someone clicking stop>start>stop with my code still hanging somewhere in the middle. I have tried using OnEvent during databasing and the like, but find it's actually a lot Easier to just have the person wait till I'm ready for them, rather than the other way around.

Share this post


Link to post
Share on other sites
bhoar

OnEvent is technically a 'better' way to handle many things, but I've found that it requires more code to determine the state of the program. I wouldnt want someone clicking stop>start>stop with my code still hanging somewhere in the middle. I have tried using OnEvent during databasing and the like, but find it's actually a lot Easier to just have the person wait till I'm ready for them, rather than the other way around.

I had some of the same concerns and thought that an event queue might be the best way to handle it. Each event gets put into a queue by *every* OnEvent handler, then the events are processed serially. Perhaps certain events would clear the queue (e.g. a STOP or CANCEL button or key combo) before being placed in the queue themselves?

-brendan

Share this post


Link to post
Share on other sites
FreeFry

OnEvent is technically a 'better' way to handle many things, but I've found that it requires more code to determine the state of the program. I wouldnt want someone clicking stop>start>stop with my code still hanging somewhere in the middle. I have tried using OnEvent during databasing and the like, but find it's actually a lot Easier to just have the person wait till I'm ready for them, rather than the other way around.

That's an excellent example of a case where message polling(GuiGetMsg()) is better than the OnEvent mode! :rolleyes:

Edit:

I mostly use OnEvent mode whenever I create a progam that has a GUI, that's supposed to do something else than handling the GUI, but at the same time I want it to respond to a users request to, for example, quit the script.

Edited by FreeFry

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×