Monday, December 11th 2017, 2:23pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

akiramaru

Beginner

Date of registration: Oct 3rd 2017

Posts: 6

1

Thursday, October 5th 2017, 7:10am

How to get GUI_SendKeyMsg event when I focused at EDIT widget?

Dear all:
Here has a problem when I focused on an EDIT widget, I can't get any KeyMsg when I press button and sent to the queue. Have anybody can help me to solve this problem, thx.

P.S. Myapplication for STemWin is only use keyboard not touch screen.

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
switch(Id) {
	case ID_EDIT_0: // Notifications sent by 'Edit'
	switch(NCode) {
		case WM_NOTIFICATION_CLICKED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
		break;
		case WM_NOTIFICATION_RELEASED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
		break;
		case WM_NOTIFICATION_VALUE_CHANGED:
			// USER START (Optionally insert code for reacting on notification message)
			// USER END
		break;
	// USER START (Optionally insert additional code for further notification handling)
	// USER END
	}
	break; }

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 440

2

Friday, October 6th 2017, 2:45pm

Hi,

Unfortunately, you can not react on key messages like you react on e.g. value changed. To react on key messages you have to set a custom callback for the edit widget itself.

Attached you will find a short example on how this can be done. It shows the custom callback and how to distinguish between the different keys.

Regards
Sven
SEGGER - Schoenen has attached the following file:
  • KeyMsg.zip (1.08 kB - 76 times downloaded - Last download: Dec 9th 2017, 4:41pm)

akiramaru

Beginner

Date of registration: Oct 3rd 2017

Posts: 6

3

Wednesday, October 11th 2017, 7:38am

Dear Sir:
Thanks for your support, I am try to learn it. :thumbup:

akiramaru

Beginner

Date of registration: Oct 3rd 2017

Posts: 6

4

Thursday, October 12th 2017, 8:51am

Dear Sir:
I have tried your code but it doesn't work well, please see attach pic. I set my BUTTON_ENTER value is 0x81A but i got KeyMsg on _cbEDIT0 is 0x10000000 they are doesn't match, could you solve these problem? Thanks.
Hi,

Unfortunately, you can not react on key messages like you react on e.g. value changed. To react on key messages you have to set a custom callback for the edit widget itself.

Attached you will find a short example on how this can be done. It shows the custom callback and how to distinguish between the different keys.

Regards
Sven
akiramaru has attached the following image:
  • keymsg.png

akiramaru

Beginner

Date of registration: Oct 3rd 2017

Posts: 6

5

Friday, October 20th 2017, 4:28am

Dear Sir:
Sorry for my eye's karma, your method is right. It's really can get keyMsg when I press the button.

Mr. Spock

Beginner

Date of registration: May 19th 2009

Posts: 16

6

Monday, October 30th 2017, 11:44pm

Hi

I want to use the example in KeyMsg.zip to end a dialog when GUI_KEY_F1 is pressed. The problem is that I canot get the handle of the dialog. Function WM_GetParent(pMsg->hWin) does not work here.

Regards

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 440

7

Monday, November 6th 2017, 8:35am

Hello Mr. Spock,

You can use WM_GetParent(pMsg->hWin) and use the returned handle to delete the parent. The problem is that the background window doesn't 'know' how to redraw itself and the deleted dialog will be still visible.

Set a callback function for the background window and the dialog will disappear after deleting.

Like:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*********************************************************************
*
*   	_cbBk
*/
static void _cbBk(WM_MESSAGE * pMsg) {
  switch (pMsg->MsgId) {
  case WM_PAINT:
	GUI_SetBkColor(GUI_BLACK);
	GUI_Clear();
	break;
  default:
	WM_DefaultProc(pMsg);
	break;
  }
}

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	MainTask
*/
void MainTask(void) {
  GUI_Init();
  WM_SetCallback(WM_HBKWIN, _cbBk);
  //
  // ...
  //
}



Live long and prosper
Sven

Mr. Spock

Beginner

Date of registration: May 19th 2009

Posts: 16

8

Monday, November 6th 2017, 11:42pm

Thank you !

Wil try

Similar threads