Hello,
I have a UI where I have several EDIT widgets to enter float values.
The device I am developing can also be controlled remotely. If the remote control is active then I have to disable the EDIT widgets.
When I disable the EDIT widgets the cursor remains blinking which suggests the user that entering values is possible (which is obviously not since it is disabled).
I already created a user defined callback for the EDIT widgets which enables and disables the blinking cursor.
This improves the behavior. If I disable the EDIT widget the cursor stops blinking but the cursor rectangle remains.
Attached you can find a simulation sample.
Is it possible to remove the cursor completely if the EDIT widget gets disabled?
Hope you can help me
Display All
I have a UI where I have several EDIT widgets to enter float values.
The device I am developing can also be controlled remotely. If the remote control is active then I have to disable the EDIT widgets.
When I disable the EDIT widgets the cursor remains blinking which suggests the user that entering values is possible (which is obviously not since it is disabled).
I already created a user defined callback for the EDIT widgets which enables and disables the blinking cursor.
This improves the behavior. If I disable the EDIT widget the cursor stops blinking but the cursor rectangle remains.
Attached you can find a simulation sample.
Is it possible to remove the cursor completely if the EDIT widget gets disabled?
Hope you can help me
C Source Code
- /*********************************************************************
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- **********************************************************************
- * *
- * (c) 1996 - 2017 SEGGER Microcontroller GmbH & Co. KG *
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- ** emWin V5.46 - Graphical user interface for embedded applications **
- emWin is protected by international copyright laws. Knowledge of the
- source code may not be used to write a similar product. This file may
- only be used in accordance with a license and should not be re-
- distributed in any way. We appreciate your understanding and fairness.
- ----------------------------------------------------------------------
- File : WIDGET_SimpleProgbar.c
- Purpose : Demonstrates the use of the PROGBAR widget
- Requirements: WindowManager - (x)
- MemoryDevices - ( )
- AntiAliasing - ( )
- VNC-Server - ( )
- PNG-Library - ( )
- TrueTypeFonts - ( )
- ----------------------------------------------------------------------
- */
- #include "GUI.h"
- #include "TEXT.h"
- #include "EDIT.h"
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- //
- // Recommended memory to run the sample with adequate performance
- //
- #define RECOMMENDED_MEMORY (1024L * 5)
- /*******************************************************************
- *
- * static code
- *
- ********************************************************************
- */
- void BkCb(WM_MESSAGE *Msg)
- {
- }
- void GUIU_EditCb(WM_MESSAGE * Msg)
- {
- GUI_RECT EditShape;
- unsigned char CursorPos;
- if (Msg->MsgId == WM_NOTIFY_ENABLE)
- {
- if (WM_IsEnabled(Msg->hWin))
- {
- /* start cursor blinking if the widget gets enabled */
- EDIT_EnableBlink(Msg->hWin, 500, 1);
- }
- else
- {
- /* stop cursor blinking if the widget gets disabled and hide the
- virtual keypad icon */
- EDIT_EnableBlink(Msg->hWin, 500, 0);
- }
- }
- /* execute the default widget callback function */
- switch (Msg->MsgId)
- {
- default:
- EDIT_Callback(Msg);
- }
- }
- static void _cbDoSomething(WM_HWIN hWin, void * p)
- {
- if (*(unsigned int*)p != 1)
- {
- WIDGET_SetFocusable(hWin, 0);
- WM_DisableWindow(hWin);
- }
- else
- {
- WIDGET_SetFocusable(hWin, 1);
- WM_EnableWindow(hWin);
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- WM_HWIN Item;
- unsigned int Counter = 0;
- unsigned int EnableState;
- GUI_Init();
- /* Set UTF-8 encoding */
- GUI_UC_SetEncodeUTF8();
- //
- // Check if recommended memory for the sample is available
- //
- if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
- GUI_ErrorOut("Not enough memory available.");
- return;
- }
- GUI_SetBkColor(GUI_WHITE);
- GUI_Clear();
- GUI_SetColor(GUI_BLACK);
- GUI_SetFont(&GUI_Font24_ASCII);
- GUI_DispStringHCenterAt("EDIT disable test", 160, 5);
- WM_SetCallback(WM_HBKWIN, BkCb);
- Item = TEXT_CreateEx(5, 50, 400, 40, WM_HBKWIN, WM_CF_SHOW, TEXT_CF_LEFT|TEXT_CF_VCENTER, GUI_ID_TEXT0, "Widgets enabled");
- TEXT_SetFont(Item, GUI_FONT_20_ASCII);
- TEXT_SetTextColor(Item, GUI_DARKGREEN);
- TEXT_SetBkColor(Item, GUI_WHITE);
- /* generate some EDIT widgets */
- Item = EDIT_CreateEx(5, 100, 125, 40, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT0, 10U);
- EDIT_EnableBlink(Item, 500, 1);
- EDIT_SetFloatMode(Item, 0, 0, 100, 2, 0);
- WM_SetCallback(Item, GUIU_EditCb);
- Item = EDIT_CreateEx(5, 150, 125, 40, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT1, 10U);
- EDIT_EnableBlink(Item, 500, 1);
- EDIT_SetFloatMode(Item, 0, 0, 100, 2, 0);
- WM_SetCallback(Item, GUIU_EditCb);
- Item = EDIT_CreateEx(5, 200, 125, 40, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT2, 10U);
- EDIT_EnableBlink(Item, 500, 1);
- EDIT_SetFloatMode(Item, 0, 0, 100, 2, 0);
- WM_SetCallback(Item, GUIU_EditCb);
- WM_SetFocus(Item);
- while(1) {
- GUI_Delay(3600);
- EnableState = (Counter++) & 0x1;
- WM_ForEachDesc(WM_HBKWIN, _cbDoSomething, (void *)&EnableState);
- Item = WM_GetDialogItem(WM_HBKWIN, GUI_ID_TEXT0);
- if (EnableState)
- {
- TEXT_SetTextColor(Item, GUI_DARKGREEN);
- TEXT_SetText(Item, "Widgets enabled");
- }
- else
- {
- TEXT_SetTextColor(Item, GUI_RED);
- TEXT_SetText(Item, "Widgets disabled but cursor rectangle remains");
- }
- /* execute the GUI function */
- GUI_Exec();
- }
- }
- /*************************** End of file ****************************/