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 » callbacks and objects
callbacks and objects [message #19017] Wed, 05 November 2008 23:06 Go to next message
sapiency is currently offline  sapiency
Messages: 56
Registered: September 2008
Member
Hi,

I want to use one callback for multiple elements. Is it possible to use the element in the callback?

example:


class TEST
{
...
  public: 
  typedef TEST CLASSNAME;

  TEST();

  void OnChange();

  EditString s1;
  EditString s2;
  ...
};

TEST::TEST()
{
  Add(s1);
  Add(s2);
  s1.WhenAction = THISBACK(OnChange);
  s2.WhenAction = THISBACK(OnChange);
  ...
}

TEST::OnChange()
{
  OUTPUT(sx.GetData());
}



If I use THISBACK1 I got the message that the Upp::Ctrl& is private. If I use sn in the Callback, it works, but then I need one callback for each field ...

second:

I look for catching key events from special keys (return, Fn, ...). How can I catch them?

regards reinhard

Re: callbacks and objects [message #19023 is a reply to message #19017] Thu, 06 November 2008 09:28 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sapiency wrote on Wed, 05 November 2008 17:06

Hi,

I want to use one callback for multiple elements. Is it possible to use the element in the callback?

example:


class TEST
{
...
  public: 
  typedef TEST CLASSNAME;

  TEST();

  void OnChange();

  EditString s1;
  EditString s2;
  ...
};

TEST::TEST()
{
  Add(s1);
  Add(s2);
  s1.WhenAction = THISBACK(OnChange);
  s2.WhenAction = THISBACK(OnChange);
  ...
}

TEST::OnChange()
{
  OUTPUT(sx.GetData());
}



If I use THISBACK1 I got the message that the Upp::Ctrl& is private. If I use sn in the Callback, it works, but then I need one callback for each field ...



I am sorry, but it is not quite clear what you are really doing Smile

Use THISBACK1 if you want to pass some parameter with callback (specified inside THISBACK1, like

void TEST::OnChange(EditField *sx) { OUTPUT(sx->GetData()); }
....
s1 <<= THISBACK1(OnChange, &s1);
s2 <<= THISBACK1(OnChange, &s2);


Quote:


I look for catching key events from special keys (return, Fn, ...). How can I catch them?



Override Ctrl::Key or Ctrl::HotKey. Check propagation rules in Ctrl reference.

Mirek
Previous Topic: what is gates
Next Topic: Execute(), LPARAM and WPARAM
Goto Forum:
  


Current Time: Fri Mar 29 16:09:56 CET 2024

Total time taken to generate the page: 0.01317 seconds