Using event handlers!
Using event handlers!
THE LIBRARY IS NOW COMPLETE. SEE THE FOLLOWING THREAD FOR DETAILS.
http://www.purebasic.fr/english/viewtop ... 768#138768
http://www.purebasic.fr/english/viewtop ... 768#138768
Last edited by srod on Tue Apr 11, 2006 5:09 pm, edited 3 times in total.
I may look like a mule, but I'm not a complete ass.
Re: Using event handlers!
Hello srod,
looks very good!
Keep it up!
Greetings ... Kiffi
looks very good!

Keep it up!

Greetings ... Kiffi
srod,
Very good!
I added a few gadgets to your demo program and everything seems to work fine.
I'd be happy to help you with the testing and/or development, if you'd like.
One mistake I noticed in the User Guide:
In the description of the Event Handler functions, the second event constant
should be "#OnLostFocus", not "#OnLostEnter".
Regards,
Eric
Very good!

I added a few gadgets to your demo program and everything seems to work fine.
I'd be happy to help you with the testing and/or development, if you'd like.
One mistake I noticed in the User Guide:
In the description of the Event Handler functions, the second event constant
should be "#OnLostFocus", not "#OnLostEnter".
Regards,
Eric
Thanks for the replies. It's early days yet, but I think the 'foundations' have been laid.
Thanks ebs, I'll tidy that up later tonight.
Doh!One mistake I noticed in the User Guide:
In the description of the Event Handler functions, the second event constant
should be "#OnLostFocus", not "#OnLostEnter".

I may look like a mule, but I'm not a complete ass.
Update:
Now covers 15 standard events including menu item / toolbar button selections; painting, sizing, moving, maximizing windows, gadget activation / deactivation plus the more familar mouse / cursor events etc.
Will add a few more what I would call 'generic' events and then will move on to specific types of gadgets and their underlying windows messages etc.
Again, thanks to any able to help out with the testing.
See the first post for the download link.
Now covers 15 standard events including menu item / toolbar button selections; painting, sizing, moving, maximizing windows, gadget activation / deactivation plus the more familar mouse / cursor events etc.
Will add a few more what I would call 'generic' events and then will move on to specific types of gadgets and their underlying windows messages etc.
Again, thanks to any able to help out with the testing.

See the first post for the download link.
I may look like a mule, but I'm not a complete ass.
srod,
I just tried out your new version and I'm liking it more and more! There isn't that much I really like about Visual Basic, but its "event model" can be pretty handy.
I noticed a convenient thing when using the "#OnButtonClick" event handler: the "wParam" field in the sender structure holds the PB gadget number.
This makes it easy to associate multiple controls (like option buttons) to one event handler, then determine which control was clicked by examining wParam.
This is similar to Visual Basic's control arrays. Do you know if this is true for other event types?
Regards,
Eric
I just tried out your new version and I'm liking it more and more! There isn't that much I really like about Visual Basic, but its "event model" can be pretty handy.
I noticed a convenient thing when using the "#OnButtonClick" event handler: the "wParam" field in the sender structure holds the PB gadget number.
This makes it easy to associate multiple controls (like option buttons) to one event handler, then determine which control was clicked by examining wParam.
This is similar to Visual Basic's control arrays. Do you know if this is true for other event types?
Regards,
Eric
Yes, forgot to document that! Sorry. I'll write a better user guide tonight, it's a bit of a mess at the moment.ebs wrote:I noticed a convenient thing when using the "#OnButtonClick" event handler: the "wParam" field in the sender structure holds the PB gadget number.
This makes it easy to associate multiple controls (like option buttons) to one event handler, then determine which control was clicked by examining wParam.
This is similar to Visual Basic's control arrays. Do you know if this is true for other event types?
The same is true for the "#OnMenuItemSelect" event which works for menus and toolbar buttons in exactly the same way that the regular Purebasic message system operates.
Thanks for testing.
I may look like a mule, but I'm not a complete ass.
Whow! I love your code! 
Here is another simple example for your demo2.pb:
Thanks again & Greetings ... Kiffi

Here is another simple example for your demo2.pb:
Code: Select all
;The following event procedure allows only numbers.
Procedure.l KeyPress(*sender.PB_Sender)
Protected result
If FindString("1234567890"+Chr(8), Chr(*sender\wParam), 1)
result = #PB_ProcessPureBasicEvents
Else
result = 0 ;This ensures the character is ignored.
EndIf
ProcedureReturn result
EndProcedure
Glad you like it.
Nice example, although Purebasic allows numeric only string gadgets through the #PB_String_Numeric flag.
Wait, I've just noticed the #PB_String_UpperCase flag!!! Doh!
Was that added for PB 4? I haven't noticed that one before!
Oh well, the principle remains though in that the #OnKeyPress event allows for a heck of a lot of possible customising.
Thanks.
Nice example, although Purebasic allows numeric only string gadgets through the #PB_String_Numeric flag.
Wait, I've just noticed the #PB_String_UpperCase flag!!! Doh!

Oh well, the principle remains though in that the #OnKeyPress event allows for a heck of a lot of possible customising.
Thanks.
I may look like a mule, but I'm not a complete ass.
Update:
Bugs fixed, more events added (coloured blue below). Also more demo progs including drag and drop to a list icon.
The full list of currently supported events runs as follows:
See post 1 for download link.
Bugs fixed, more events added (coloured blue below). Also more demo progs including drag and drop to a list icon.
The full list of currently supported events runs as follows:
- #OnButtonClick
- #OnChange
- #OnClose
- #OnContextMenuPopup
- #OnCursorEnter
- #OnCursorExit
- #OnDragDrop
- #OnDblClick
- #OnGotFocus
- #OnKeyDown
- #OnKeyPress
- #OnKeyUp
- #OnLostFocus
- #OnMaximize
- #OnMenuItemSelect
- #OnMinimize
- #OnMouseDown
- #OnMouseOver
- #OnMouseUp
- #OnMove
- #OnPaint
- #OnResize
See post 1 for download link.
I may look like a mule, but I'm not a complete ass.
-
- Addict
- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact: