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 #24213 is a reply to message #24202] Tue, 05 January 2010 17:55 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
There are two additional options you missed out:

3- Catch unhandled key presses in the Ctrls owner/parent. ie:
virtual void Key(dword key, int count)
{
    if (key == K_RETURN && password_field.HasFocus())
       login.PseudoPush();
    else
       return false;
    return true;
}
Since you'd have to declare a new function to handle a callback anyway this isn't really any extra code.

4- Create a simple template to automate callback functionality:
template <class T>
struct WithCallbacks : public T {
   Callback WhenLeftDown

   virtual void LeftDown(Point p, dword keyflags) { WhenLeftDown(); }
}
...
WithCallbacks<ArrayCtrl> array;
Given all the possible methods it doesn't seem worth retro-actively adding callbacks everywhere.

OTOH, the K_RETURN event for EditField is common enough to warrant it's addition. It should be called WhenReturn or maybe WhenKeyReturn to match the key enum though. WhenEnter is too easy to confuse with the focus changing IMO.


 
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: Tue Jun 04 11:58:19 CEST 2024

Total time taken to generate the page: 0.01746 seconds