Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » Virtual functions versus callbacks
Re: Virtual functions versus callbacks [message #24238 is a reply to message #24204] Wed, 06 January 2010 22:09 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
unodgs wrote on Tue, 05 January 2010 04:36

koldo wrote on Tue, 05 January 2010 03:59

Hello all

To let the program do actions after events I have seen there are two options in Upp:

- To use "virtual" functions
For example to get the "enter" key in an EditField it is necessary to do a derived class
that catches virtual bool Key(dword key, int rep);

- To use callback
For example to do something after clicking in an ArrayCtrl it could be done by assigning a callback function to "WhenLeftClick".

From the user (programmer) point of view it seems better callback functions as you do not need to do derived classes every time you need a certain response after a Ctrl event.

Personally I stronger prefer callback but, what do you think about it ?

Best regards
Koldo

In my upp sources EditField has WhenEnter callback. I guess it could be added to the main tree as now I can see I'm not the only one who needs it Smile


Just to be sure, if callback is empty, Enter is ignored and passed to the parent?

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: mini BUGFIX in CallbackArgTarget
Next Topic: extracted Timer from Ctrl
Goto Forum:
  


Current Time: Thu May 16 20:07:50 CEST 2024

Total time taken to generate the page: 0.01536 seconds