Home » Community » Newbie corner » text box action with enter key
Re: text box action with enter key [message #25100 is a reply to message #25092] |
Wed, 10 February 2010 13:07   |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class LaunchField : public EditField
{
public:
virtual bool Key(dword key, int count);
Callback WhenEnter;
typedef LaunchField CLASSNAME;
LaunchField() {}
~LaunchField() {}
};
bool LaunchField::Key(dword key, int count)
{
if(key == K_ENTER) {
WhenEnter();
return true;
}
return EditField::Key(key, count);
}
//==============================================
class MyApp : public TopWindow {
public:
LaunchField box1, box2;
void OnEnter1();
typedef MyApp CLASSNAME;
MyApp();
~MyApp() {}
};
MyApp::MyApp()
{
box1.WhenEnter = THISBACK(OnEnter1);
Add(box1.TopPosZ(0, 20).HSizePos());
Add(box2.TopPosZ(20, 20).HSizePos());
SetRect(0, 0, 200, 60); //if you really need
Zoomable().Sizeable().Title("CallbackField Demo");
}
void MyApp::OnEnter1()
{
box2<<= ~box1;
PromptOK("you can launch a rocket from here! but better replace me with your code!");
}
//==============================================
GUI_APP_MAIN
{
MyApp app;
app.Run();
}
I hope to hear something from you... like ... more questions!
Aris
[Updated on: Wed, 10 February 2010 13:10] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Aug 24 13:10:16 CEST 2025
Total time taken to generate the page: 0.04403 seconds
|