Page 1 of 2

new Eventsystem

Posted: Thu Nov 05, 2009 7:33 pm
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

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:04 pm
by Kiffi
hallodri wrote:Please add a new eventsystem, like vb.net, flex, wxwidget etc.
+1

Greetings ... Kiffi

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:07 pm
by Fred
There is nothing confusing in the current event handler, it's even more logical than callback based one.

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:20 pm
by PB

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:25 pm
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

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:29 pm
by ts-soft
+1

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:44 pm
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!

Re: new Eventsystem

Posted: Thu Nov 05, 2009 8:48 pm
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

Re: new Eventsystem

Posted: Thu Nov 05, 2009 9:02 pm
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. :)

Re: new Eventsystem

Posted: Thu Nov 05, 2009 10:50 pm
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.

Re: new Eventsystem

Posted: Thu Nov 05, 2009 11:26 pm
by Marlin
I like the PB eventsystem as it is.

I find it simple, nice, logical, flexible, not bloated with unneeded overhead...

Re: new Eventsystem

Posted: Thu Nov 05, 2009 11:45 pm
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.

Re: new Eventsystem

Posted: Fri Nov 06, 2009 3:27 am
by Mistrel
This is very similar in how Java Swing works as well. I didn't know other APIs used this method as well.

Re: new Eventsystem

Posted: Fri Nov 06, 2009 9:03 am
by PB
> IMHO, PB's current event handling cannot get any simpler!

+1

Re: new Eventsystem

Posted: Fri Nov 06, 2009 9:45 am
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