393 views
in GUI Development by
hi ,

I have written the code for pressed F1 with keypad Handler

for key pressed

var Views::Text SelectedButton = null;

switch( KeyHandler.Code ) {
   case Core::KeyCode.F1: SelectedButton = Button1;
   case Core::KeyCode.F2: SelectedButton = Button2;
   case Core::KeyCode.F3: SelectedButton = Button3;
   default:;
}

 

/*************

for key release

var Views::Text SelectedButton = null;
switch( KeyHandler.Code ) {
   case Core::KeyCode.F1: SelectedButton = Button1;
   case Core::KeyCode.F2: SelectedButton = Button2;
   case Core::KeyCode.F3: SelectedButton = Button3;
   default:;
}

  if (SelectedButton == Button1) {
   trace "F1 pressed";
   }

 

So when Button1 is pressed it always remains in that position .

I have continuous going process when some action is performed when a particular key is pressed i want to send a string and resume to its particular process ,

In my case it remains it in  key pressed loop and i always get as F1 pressed";

1 Answer

0 votes
by
Hello Pidea,

I'm sorry, but I don't understand your question. Can you explain the problem or the desired function more in detail? Or provide some example demonstrating the problem?

Best regards

Paul Banach
by
hi paul,

i will need some time to create sample project. Meanwhile i want to ask If i have to run continuous process from UI application without based environment .then in which part i need to include . For example for win32 based environment i called it from main() function so in Embedded Wizard which is that function that is called first and can be run.Is it method init()?
by
key pressed release retain it previous state . how should i clear the previous state
by

hi ,

 

please refer the project.

three screen are there , rootscreen, firstscreen, second screen 

Timer is implemented which trigger the key released slot and check any key is pressed ..

Problem is for second iteration keyHandler retains its previous state . Which is the parameter that can clear the state of key 

 

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=5604950924937601470

 

by

Hello Pidea,

thank you for the example. So far I could see the continuously log messages ''checkkeypressed' and 'lot - onKeyRelease'. This is caused by the method onKeyRelease being invoked in context of Timer. The call stack window reveals the situation:

The method onKeyRelease is invoked in two cases: (1) by the KeyHandler when the user releases the key and (2) by the Timer object as shown in the screenshot above.

The problem with this approach is, the method evaluates the variable Code from the KeyHandler. This variable (similar to other state variables existing the KeyHandler) is valid only while the KeyHandler triggers its associated slot method (e.g. OnPress, OnHold or OnRelease). Evaluating the variable at any other time point will result in the recent code (recent state) processed by KeyHandler.

You will need to adapt your code so that when the method onKeyRelease is executed in context of the Timer, the variable Code is not evaluated:. Following could be the adaptation. The affected modifications are highlighted:

Does the modification work as expected?

Best regards

Paul Banach

by

Hello Pidea,

concerning your second question:

Meanwhile i want to ask If i have to run continuous process from UI application without based environment .then in which part i need to include . For example for win32 based environment i called it from main() function so in Embedded Wizard which is that function that is called first and can be run.Is it method init()?

I have again difficulties to understand what you mean. Can you please explain what you intend to do?

Best regards

Paul Banach

by
Hi Paul,

modification work as expected thank you .

 

Concerning second question

1. If i have to run continuous task () from Embedded wizard, is there any special function that i can used .?
by

Hello Pidea,

I suppose, with "continues task" you mean a separate process or thread? If yes, Embedded Wizard itself does not provide such functionality. If you have an OS then you can of course use it to start a separate thread/process. Doing this, however, you should ensure that Embedded Wizard code is executed in context of the main thread only. See also section Avoid multithreading.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...