It is currently Sat Nov 25, 2017 2:58 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Bind...Event() with additional paramter
PostPosted: Fri Oct 06, 2017 7:22 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 582
An additional parameter in the Bind... Event () commands would be very useful, e. g. for a this-pointer. Ok, I can store this as Data in the Window/Gadget, but that's not very elegant.

In the forum I found several posts about this, but obviously nobody thought about posting this also in the Wishlists.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Fri Oct 06, 2017 10:59 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 871
Is EventData() an option ?

_________________
PureBasic 5.45 LTS / 5.61 (Windows x86/x64) | Windows10 Pro x64 | Z87-PLUS | i7 4770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language...


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Fri Oct 06, 2017 1:52 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 503
+1 It is a very common practice for a callback to supply a value that gets passed to the callback.
Eventdata is just for customs events no? And may be in use for other things.
I have been missing this since events were introduced but i did not bother to ask because i have very few hopes it gets included.


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Sat Oct 07, 2017 12:09 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3425
Location: Utah, USA
Do you have example code that demonstrates the way the proposed change would be used?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Sat Oct 07, 2017 9:25 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 134
Demivec wrote:
Do you have example code that demonstrates the way the proposed change would be used?


It would be very helpful for custom/complex GUIs or games.

Image

Im not sure why anyone would prefer this or EventData() over a additional parameter.
Code:
*Chess.CHESS_STRUCT = GetGadgetData(EventGadget())


+1


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Sat Oct 07, 2017 12:39 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
I think is a god idea

This work
Code:
;-TOP

; Comment : Module MyBindEvent with EventData
; Author  : mk-soft
; Version : v1.0x
; Created : 07.10.2017
; Updated :

; Callback syntax : BindGadgetCB(EventData)

DeclareModule MyBindEvent

  Declare MyBindGadgetEvent(Gadget, *Callback, EventType = #PB_All, EventData = 0)
  Declare MyUnbindGadgetEvent(Gadget, *Callback, EventType = #PB_All)
 
EndDeclareModule

...



Link: viewtopic.php?f=12&t=69352

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Bind...Event() with additional paramter
PostPosted: Sat Oct 07, 2017 4:30 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 134
mk-soft wrote:
I think is a god idea

This work
...


...now imagine we would not need to do workarounds :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye