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 » 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 Go to previous messageGo to previous message
fudadmin is currently offline  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... Smile like ... more questions!

Aris

[Updated on: Wed, 10 February 2010 13:10]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Clipped frame
Next Topic: is there any way to embed a browser window in a U++ window or view the html direclty?
Goto Forum:
  


Current Time: Sun Aug 24 18:45:24 CEST 2025

Total time taken to generate the page: 0.17310 seconds