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 » LineEdit, EditFields, DocEdit » double-click in EditField
double-click in EditField [message #56279] Tue, 16 February 2021 15:43 Go to next message
BetoValle is currently offline  BetoValle
Messages: 142
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

in the EditField class I didn't identify an event
WhenLeftDouble, and I wonder if there is a way
better than the rewrite according to the example below?

struct Edx: EditField{
 	typedef Edx CLASSNAME; 	
	Edx(){};
	virtual void LeftDouble(Point p, dword keyflags)
	{
		PromptOK("ok");
	}
};

GUI_APP_MAIN
{
	TopWindow  app;
	app.SetRect(0, 0, Zx(500), Zy(500));
	Edx text;
        app.Add(text.LeftPos(12,234).TopPos(63,21));
	text.SetText( "double click here");
	app.Run();
}


Re: double-click in EditField [message #56282 is a reply to message #56279] Tue, 16 February 2021 18:44 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Not sure if this is what you are looking for, but
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct Edx: EditField{
	// typedef Edx CLASSNAME; (Not needed in new code)
	
	Edx(){};
	
	// encouraged to use c++11 new language feature
	// in new code to clearly manifest that you are
	// override a parent virtual function
	//
	void LeftDouble(Point p, dword keyflags)override
	{
		WhenLeftDouble(p,keyflags);
		
		// following line should be dispensible in this
		// particular case as I expect it does nothing
		//
		this->EditField::LeftDouble(p,keyflags);
	}
	
	// the following line introduce a new Event
	// and note how it comes to effect by calling it in the
	// overrided virtual.
	//
	Event<Point, dword> WhenLeftDouble;
};

GUI_APP_MAIN
{
	TopWindow  app;
	app.SetRect(0, 0, Zx(500), Zy(500));
	Edx text;
	
	text.WhenLeftDouble<<[=](Point , dword){ PromptOK("ok"); };
    
    app.Add(text.LeftPos(12,234).TopPos(63,21));
	text.SetText( "double click here");
	app.Run();
}
Re: double-click in EditField [message #56283 is a reply to message #56282] Tue, 16 February 2021 21:39 Go to previous messageGo to next message
BetoValle is currently offline  BetoValle
Messages: 142
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member

very good! Thanks

I took advantage of this same logic for a Label and I was not able to produce the double click effect.
Label has some peculiarity in relation to EditField?


    struct: Label{
	Lb(){};
	void LeftDouble(Point p, dword keyflags)override
	{
		WhenLeftDouble(p,keyflags);
	}
	Event<Point, dword> WhenLeftDouble;
    };


icon3.gif  Re: double-click in EditField [message #56284 is a reply to message #56283] Tue, 16 February 2021 21:55 Go to previous messageGo to next message
BetoValle is currently offline  BetoValle
Messages: 142
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

in Label this work! very god mirek! https:// www.ultimatepp.org/forums/index.php?t=msg&th=7912&go to=44362&

(to activate the mouse, use NoIgnoreMouse() in constructor)

struct Lb: Label{ // Label LeftDouble double-click
	Lb(){ NoIgnoreMouse(); };
	
	void LeftDouble(Point p, dword keyflags)
	{
	    WhenLeftDouble(p,keyflags);
		this->Label::LeftDouble(p,keyflags);
	}
	Event<Point, dword> WhenLeftDouble;
};


Thanks
Re: double-click in EditField [message #56293 is a reply to message #56284] Wed, 17 February 2021 23:37 Go to previous message
Lance is currently offline  Lance
Messages: 380
Registered: March 2007
Senior Member
Thanks for sharing. I didn't know that!
Previous Topic: NotNull not working with custom SetConvert [CLOSED]
Next Topic: fill date bars automatically
Goto Forum:
  


Current Time: Sat Oct 23 15:14:13 CEST 2021

Total time taken to generate the page: 0.01097 seconds