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 » Community » Newbie corner » [solved] Widget events - any other than WhenAction ? (Trying to find equivalents of OnEnter, OnExit - in an Edit widget)
Re: Widget events - any other than WhenAction ? [message #58801 is a reply to message #58793] Sun, 04 September 2022 21:28 Go to previous message
peterh is currently offline  peterh
Messages: 108
Registered: November 2018
Location: Germany
Experienced Member
There is another - more elegant - solution:

Code your derived Ctrl as a template:
(this is experimental stuff I made for learning purposes, it works as expected, but does nothing meaningful)

template <typename TCtrl>
struct MyCtrl : public TCtrl {
	int count = 0;
	MyCtrl()//:TCtrl() // Default constructor wird automatisch aufgerufen, deshalb ist ...:MyCtrl:TCtrl() (hier) nicht notwendig, schadet aber auch nicht.
	{
		WhenEnter << []{Cout() << " Enter ";};
	}

	virtual void Paint(Draw& w) override {
		//w.DrawRect(GetSize(), White());
		TCtrl::Paint(w);
		w.DrawText(2, 2, AsString(count));
	}
};


Then you can derive arbitrary Controls from it, and the compiler will bark if there is a problem.

Then define your control in the layout editor like this:

index.php?t=getfile&id=6654&private=0

I think this should be in the tutorial.
It might be "cold coffee" to regular users, but will get new users started.

An *.usc file is not required in this case.
In most cases I want to expand or modify the behavior of an existing control.
I think this is a very common problem that new users will encounter and possibly will give up on it.
Then this comes in handy.




  • Attachment: Layout2.jpg
    (Size: 60.20KB, Downloaded 234 times)

[Updated on: Sun, 04 September 2022 21:57]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: App "swallowing" mouseclicks
Next Topic: no variables in debug mode
Goto Forum:
  


Current Time: Sun May 12 03:06:22 CEST 2024

Total time taken to generate the page: 0.03171 seconds