|
|
Home » U++ Library support » LineEdit, EditFields, DocEdit » Lost focus in edit fields
Lost focus in edit fields [message #22603] |
Thu, 30 July 2009 10:17  |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
Hi,
Is there a way to trigger a callback when edit filed loses its focus? Right now I added a callback (WhenLostFocus) to EditField::LostFocus, but maybe there is already some other method to do it?
|
|
|
|
|
|
Re: Lost focus in edit fields [message #22620 is a reply to message #22615] |
Sat, 01 August 2009 11:41   |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
Didier wrote on Sat, 01 August 2009 10:43 | It adds a callback to the type <T> and does what you want while avoiding modifying upp src.
|
I don't really mind modyfing upp src , esspecially when it is just two lines (one in *.cpp and one in *.h):
EditField.cpp :
void EditField::LostFocus()
{
if(autoformat && IsEditable() && !IsNull(text)) {
Value v = convert->Scan(text);
if(!v.IsError()) {
const Convert * cv = inactive_convert ? inactive_convert : convert;
WString s = cv->Format(v);
if(s != text) text = s;
}
}
if(!keep_selection) {
anchor = -1;
cursor = sc = 0;
WhenLostFocus();//<--here
}
Refresh();
SyncEdge();
}
[Updated on: Sat, 01 August 2009 11:42] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Lost focus in edit fields [message #27677 is a reply to message #27676] |
Thu, 29 July 2010 12:57   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Just use the one from this thread in your own code, though it doesn't need as much code as above:
template <class T>
struct WithLostFocus : public T {
Callback WhenLostFocus;
virtual void LostFocus() {
T::LostFocus();
WhenFocusLost();
}
};
[Updated on: Thu, 29 July 2010 12:58] Report message to a moderator
|
|
|
|
Re: Lost focus in edit fields [message #45067 is a reply to message #22615] |
Thu, 27 August 2015 09:05  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
my very first message so excuse the dumb question.
I am a little noob and not really experienced with C++ programming. I am trying to do the same as in this thread: add an action when focus is lost on an EditString field. I think that your solution is what I am looking for, but I do not know how to make it work. I could really use an example i.e. where to put your code and how to "connect" the lost focus event with my procedure.
Thanks in Advance.
Giorgio
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:35:47 CEST 2025
Total time taken to generate the page: 0.00733 seconds
|
|
|