lorenzo906 / m2tklib

Automatically exported from code.google.com/p/m2tklib
0 stars 0 forks source link

M2_U32NUMFN callback message when field is selected #141

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 Clemens....@physik.uni-halle.de on 5 Sep 2014 at 11:15

GoogleCodeExporter commented 8 years ago
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 olikr...@gmail.com on 7 Sep 2014 at 12:27

GoogleCodeExporter commented 8 years ago
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 Clemens....@physik.uni-halle.de on 9 Sep 2014 at 1:29

GoogleCodeExporter commented 8 years ago
ok, sounds good.

Original comment by olikr...@gmail.com on 9 Sep 2014 at 3:36