eGUI EditBox cursor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

eGUI EditBox cursor

Jump to solution
1,470 Views
GeneGoff
Contributor III

I'm using the eGUI 3.0 EditBox widget and everything works fine except I can't get the cursor to blink or even show anything.  I was able to force it on always anytime a character is written to the edit box by modifying some of the d4d_edit_box.c source code, but this is just a test.  How do I get the cursor to show normally and blink?

0 Kudos
Reply
1 Solution
1,222 Views
GeneGoff
Contributor III

Sean, I found the problem and solution - you have to enable the object to receive time ticks.  Here's a code snip:

static void ScrSave_OnActivate()

{

   D4D_EnableTimeTicks(&edit_box, D4D_TRUE);       

View solution in original post

6 Replies
1,222 Views
soledad
NXP Employee
NXP Employee

Hello Gene,

D4D_CNSL_CURSOR_BLINK_TICK_COUNTER is the constant to define the blink period, 0 is no cursor.

Please check the below thread:

D4D_CONSOLE save text


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,222 Views
seandema
Contributor IV

You need to call D4D_TimeTickPut() periodically. I think the recommendation is every 25ms. I have a loop in my code that calls D4D_Poll() followed by D4D_TimeTickPut() and I'm able to get my cursor to blink.

Hope that helps,

Sean

1,222 Views
GeneGoff
Contributor III

Yes, D4D_TimeTickPut() is being called by a 25ms timer but still no cursor.  Looking through the d4d_edit_box.c code, it appears that D4D_EditBoxTimeTick() needs to be called which toggles the cursor state, but nothing is calling this and it's a local function in d4d_edit_box.c

Also, the only function capable of drawing, or erasing the cursor is D4D_EditBoxOnDraw(), and setting a break point on this reveals that it never executes, until you enter the next editbox character.

I ensured that D4D_CURSOR_BLINK_TICK_COUNTER is not 0.

Any ideas?

Thanks Sean!

0 Kudos
Reply
1,222 Views
seandema
Contributor IV

I think I'm seeing something similar on the latest screen I've been working on. I have was trying to automatically capture the keys and get a cursor on a certain edit boxe when loading the screen but it wasn't always showing me the cursor either. Even though D4D_GetCapturedObject() would return the desired edit box and I could manipulate the contents and select characters as though the cursor were visible. This seemed to be a problem mostly the first time I loaded the screen after a reboot. Anyway I've not figured out the real cause but a work around that fixed it for me was to call D4D_Poll() after setting the focus but before calling D4D_CaptureKeys().

D4D_FocusSet(D4D_GetActiveScreen(), &edit_box);

D4D_Poll();

D4D_CaptureKeys(&edit_box);

Doesn't really fix any possible bugs that might be out there but maybe it will help you.

I have not had the problem with no cursor when I just let the user set the focus to my edit box using arrow keys(D4D_KEY_SCANCODE_UP, D4D_KEY_SCANCODE_DOWN) and then selecting the edit box with D4D_KEY_SCANCODE_ENTER. I'm just doing all that with calls like D4D_NewKeyEvent(D4D_KEY_SCANCODE_ENTER) and letting eGUI move the focus and select/capture keys on the edit box.

Hope some of that helps.

Thanks,

Sean

1,223 Views
GeneGoff
Contributor III

Sean, I found the problem and solution - you have to enable the object to receive time ticks.  Here's a code snip:

static void ScrSave_OnActivate()

{

   D4D_EnableTimeTicks(&edit_box, D4D_TRUE);       

1,222 Views
seandema
Contributor IV

Thank! That helped.

It's interesting that fixed it since it looks like edit boxes call D4D_EnableTimeTicks under the D4D_MSG_SETCAPTURE case in their OnMessage() function.

I also discovered an issue in my code. I'd been making a lot of the FocusSet & CaptureKeys calls in my screens _OnObjectMsg() function and I was always returning 0. I realized that was part of my problem and returning a 1 in certain situations instead eliminated the need to call D4D_EnableTimeTicks or D4D_Poll. Returning a 1 prevents the message from being passed on to the object since the screen gets the message first. I think letting the edit box handle the message after I already called CaptureKeys was causing the edit boxes cursor flag bit to be flipped back to 0 when it needed to be 1.

0 Kudos
Reply