Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M2_U32NUMFN callback message when field is selected #141

Open
GoogleCodeExporter opened this issue Jul 31, 2015 · 3 comments
Open

M2_U32NUMFN callback message when field is selected #141

GoogleCodeExporter opened this issue Jul 31, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

Hello,

is there a callback message for U32NUMFN that indicates, when the cursor is on 
the certain element?

My intention is to change the key assignment when editing an input field like 
U32NUM.
I tried implementing a callback function to U32NUMFN, which sets a flag to 
change key assignment:
uint32_t u32_cb(m2_rom_void_p element, uint8_t msg, uint32_t val)
{   if ( msg == M2_U32_MSG_SET_VALUE ){
            return_value=val;
        Num_Flag=1;}
    return return_value;}

Unfortunately this works only when the displayed value of the element is 
changed, not if I only shift from one digit to the next.

I would need a message that is send on all events when the cursor is on the 
input element, but only then.
Is there any? Or maybe a workaround. I believe there must be, as the the 
element needs to know when it's activated.

Thank you very much for help.

Original issue reported on code.google.com by [email protected] on 5 Sep 2014 at 11:15

@GoogleCodeExporter
Copy link
Author

You could make a copy  of m2elu32.c, rename the identifiers and implement an 
updated function M2_EL_FN_DEF(m2_el_digit_fn)

Within m2_el_digit_fn you can get the current position with 
m2_el_u32_get_digit_pos(fn_arg->nav)


Original comment by [email protected] on 7 Sep 2014 at 12:27

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Thank you.

Unfortunately, I was not talented enough to use your suggestions.
After some trial and error I was able to put a Num_Flag close to the end of the 
file you mentioned.
Here:
case M2_EL_MSG_SHOW:
      if ( fn_arg->arg == 1 )
      {
          Num_Flag=1;
    m2_pos_p b = (m2_pos_p)(fn_arg->data);
    uint8_t w = m2_fn_get_width((fn_arg->element));
    uint8_t h = m2_fn_get_height((fn_arg->element));
    m2_gfx_normal_parent_focus(b->x, b->y, w, h, font);
    return 0;
      }
      break; 

Now the flag is true whenever the cursor is on a numerical field. 
That's what I need to freely reassign my keys whenever I enter a u32num input 
field.

Original comment by [email protected] on 9 Sep 2014 at 1:29

@GoogleCodeExporter
Copy link
Author

ok, sounds good.

Original comment by [email protected] on 9 Sep 2014 at 3:36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant