new Eventsystem

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

new Eventsystem

Post by hallodri »

Please add a new eventsystem, like vb.net, flex, wxwidget etc.
The current eventsystem is .. confusing?

Pseudocode :

Code: Select all

Procedure OnButtonClick0(*event.ButtonEvent) 
  Debug "button 0 click"
  ProcedureReturn #True
EndProcedure

Procedure OnButtonClick1(*event.ButtonEvent) 
  Debug "button 1 click"
  ProcedureReturn #True
EndProcedure

Procedure OnWindowResize(*event.WindowEvent) 
  Debug "Resize window"
  ProcedureReturn #True
EndProcedure

Procedure OnWindowClose(*event.WindowEvent)
  Debug "Close window"
  ; exit StartAndWaitWindow(0)
  ProcedureReturn #True
EndProcedure

Procedure Main()  
  
  If OpenWindow(0,0,0,100,100,"")
    
    ButtonGadget(0,0,0,75,23,"Button0")
    ButtonGadget(1,0,30,75,23,"Button1")
    
    SetGadgetEventHandler(0,#OnClick ,@OnButtonClick0())
    SetGadgetEventHandler(1,#OnClick ,@OnButtonClick1())   
 
    SetWindowEventHandler(0,#OnResize,@OnWindowResize())
    SetWindowEventHandler(0,#OnClose ,@OnWindowClose())
    
    StartAndWaitWindow(0) ; :D
    
  EndIf 
  
EndProcedure
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: new Eventsystem

Post by Kiffi »

hallodri wrote:Please add a new eventsystem, like vb.net, flex, wxwidget etc.
+1

Greetings ... Kiffi
Hygge
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: new Eventsystem

Post by Fred »

There is nothing confusing in the current event handler, it's even more logical than callback based one.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: new Eventsystem

Post by PB »

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: new Eventsystem

Post by Kiffi »

yes, there are several solutions. The best solution is IMO EasyVENT from srod.
But nevertheless it would be pretty cool if PB supports this natively.

Greetings ... Kiffi
Hygge
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: new Eventsystem

Post by ts-soft »

+1
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Re: new Eventsystem

Post by Kale »

hallodri wrote:Please add a new eventsystem, like vb.net, flex, wxwidget etc.
The current eventsystem is .. confusing?
If you are going to request this style of event handling then you really need an OOP based language. IMHO, PB's current event handling cannot get any simpler!
--Kale

Image
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: new Eventsystem

Post by rsts »

Don't know enough about other systems to comment on them. Seems I've been able to accomplish about everything I need with PB.

However, if you do "add a new eventsystem", PLEASE don't break the existing system. I would hate to have to change my entire eventhandling in order to upgrade to a new version.

Thanks.

cheers
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: new Eventsystem

Post by srod »

If you are going to request this style of event handling then you really need an OOP based language. IMHO, PB's current event handling cannot get any simpler!
As much as I like OOP, I don't see how OOP is needed in order to make good use of event-handlers?

Must admit that whilst I am no great fan of PB's event loop, it is nevertheless good enough for most purposes. Having said this, it is true that I rarely use a PB event loop other than to give me a convenient message retrieval loop. All of my Windows GUI programs use event-handlers.

It would be a nice addition to PB for sure, but not absolutely essential. :)
I may look like a mule, but I'm not a complete ass.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Re: new Eventsystem

Post by Kale »

srod wrote:As much as I like OOP, I don't see how OOP is needed in order to make good use of event-handlers?
If you take a look at his requested event syntax it's clear that it would become a gigantic mess of replication. OOP would be a prefered solution to avoid this to overload the event handlers to make them more generic. Also, the way the event 'object' (structure) is passed as a parameter is again replication. Obviously you wouldn't have a seperate event object for each event, you just pass a generic one which contains information about what event just happened. See C#'s event system, it works this way.
--Kale

Image
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Re: new Eventsystem

Post by Marlin »

I like the PB eventsystem as it is.

I find it simple, nice, logical, flexible, not bloated with unneeded overhead...
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: new Eventsystem

Post by DoubleDutch »

The best solution is IMO EasyVENT from srod.
I agree, EasyVent is great, but I also like the normal PureBasic Event loop too.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: new Eventsystem

Post by Mistrel »

This is very similar in how Java Swing works as well. I didn't know other APIs used this method as well.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: new Eventsystem

Post by PB »

> IMHO, PB's current event handling cannot get any simpler!

+1
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: new Eventsystem

Post by ts-soft »

> IMHO, PB's current event handling cannot get any simpler!
But you can't catch timerevent, sizeevent and so on for example while moving the window. I have always to use a callback.
But this is not multiplattform, so a better eventsystem is required!

Greetings
Thomas
Post Reply