Home » U++ Library support » U++ Widgets - General questions or Mixed problems » EditString validation
EditString validation [message #20065] |
Mon, 16 February 2009 00:10 |
Kajko
Messages: 14 Registered: December 2008 Location: Ireland, Serbia
|
Promising Member |
|
|
Hi everybody...
I have interesting problem. Code:
class ccc : public TopWindow {
public:
typedef ccc CLASSNAME;
EditString str1;
EditString str2;
EditString str3;
ccc()
{
SetRect( 0, 0, HorzLayoutZoom(430), VertLayoutZoom(485) );
Add(str1.LeftPosZ(100, 300).TopPosZ(10, 20));
Add(str2.LeftPosZ(100, 300).TopPosZ(30, 20));
Add(str3.LeftPosZ(100, 300).TopPosZ(50, 20));
};
};
GUI_APP_MAIN
{
ccc().Run();
}
Is there anyway to validate string input BEFORE string lose focus and prohibit losing focus if valid fails ?
I will try to explain better...
Let say that only valid input in str2 is str1 + something. When user wants to leave str2 (K_ENTER, K_UP, K_DOWN, etc...) I would like to validate str2 and keep focus on str2 until text entered is not right.
I do not know did i make my self clear...
Cheers
Sasa
b78a07c7fb9b68436af9fd23f4e76cc5
|
|
|
|
Re: EditString validation [message #20078 is a reply to message #20065] |
Mon, 16 February 2009 14:16 |
Kajko
Messages: 14 Registered: December 2008 Location: Ireland, Serbia
|
Promising Member |
|
|
Thanks for an answer...
now look at this if you please:
class ccc : public TopWindow {
public:
typedef ccc CLASSNAME;
EditString str1;
EditString str2;
EditString str3;
ccc()
{
SetRect( 0, 0, HorzLayoutZoom(430), VertLayoutZoom(485) );
Add(str1.LeftPosZ(100, 300).TopPosZ(10, 20));
Add(str2.LeftPosZ(100, 300).TopPosZ(30, 20));
str2.cbValid << THISBACK( validStr2 );
Add(str3.LeftPosZ(100, 300).TopPosZ(50, 20));
};
bool validStr2()
{
PromptOK( "ss" );
return true;
}
};
GUI_APP_MAIN
{
ccc().Run();
}
in CtrlCore.h i added:
class Ctrl : public Pte<Ctrl> {
public:
>>>>>>>>>THIS>>>>>>> Gate cbValid;
...
and in Ctrl.cpp i added this:
void Ctrl::LostFocus() {
>>>>>>>>>THIS>>>>>>> if( cbValid() )
>>>>>>>>>THIS>>>>>>> SetFocus();
}
so if cbValid() return true, stay where you are )
BUT validStr2 HAS NEVER been called. Any idea why ?
Thanks,
Sasa
b78a07c7fb9b68436af9fd23f4e76cc5
|
|
|
|
Re: EditString validation [message #20080 is a reply to message #20065] |
Mon, 16 February 2009 16:09 |
Kajko
Messages: 14 Registered: December 2008 Location: Ireland, Serbia
|
Promising Member |
|
|
Thanks.
That worked...i was just thinking general approach )
Thanks again
Sasa
b78a07c7fb9b68436af9fd23f4e76cc5
|
|
|
Goto Forum:
Current Time: Fri Mar 29 02:44:06 CET 2024
Total time taken to generate the page: 0.01389 seconds
|