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 » Focus problem
Focus problem [message #57784] Tue, 14 December 2021 21:23 Go to previous message
Silvan is currently offline  Silvan
Messages: 56
Registered: December 2014
Location: Trento (IT)
Member
Problem description:

in the simple test app below I can't unfocus the editstring ctrl so when I use the keyboard to move
the character on the string the key pressed goes also on the edit control.

I suppose it is silly but I can't find a simple solution and I don't understand the focus and
event mechanism.

Greetings
Thank you
Silvan


#include <CtrlLib/CtrlLib.h>

using namespace Upp;


struct MainWindow : TopWindow {

Point p;
EditString inputtext;

virtual void Paint(Draw& w)override
{
int x,y;

w.DrawRect(GetSize(), SWhite());

w.DrawText(p.x, p.y, "#", Arial(30), Red);

}

void Close() override
{
delete this;
}

virtual bool Key(dword key, int count) override
{

switch (key)
{
case K_W:
p.y-=1;
break;
case K_S:
p.y+=1;
break;
case K_A:
p.x-=1;
break;
case K_D:
p.x+=1;
break;
default:
//C Statements
;
}

Refresh();
return true;
}

// Costruttore dove inserisci le inizializzazioni
MainWindow()
{

Title("Test Focus").Zoomable().Sizeable();
Add(inputtext.TopPosZ(0, 16).HSizePos());
inputtext <<= "test";

SetRect(0, 0, 300, 300);
p.x = 150;
p.y = 150;
}
};
GUI_APP_MAIN
{
(new MainWindow)->OpenMain();
Ctrl::EventLoop();
}





 
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
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to output variable values with time stamp in windows application
Next Topic: Clang linker error: no such file or directory
Goto Forum:
  


Current Time: Wed May 15 10:06:41 CEST 2024

Total time taken to generate the page: 0.01446 seconds