onChange event with readonly = true

If the "readonly" flag is set and "format" is configured. The event "onChange" is called.

To reproduce:
1) Select the upper input;
2) Select the lower input (with the mouse or using the tab key).

https://snippet.webix.com/exvkmh5k

https://i.imgur.com/OTGk4as.mp4

Tagged:

Comments

  • Hello @lBeJIuk,
    It's not bug. The readonly property doesn't affect here, that with this property, that without it, the result is the same.
    https://docs.webix.com/desktop__text.html#settingnumberformat -

    • edit - responsible for taking the actual value of control and drawing it in the input
    • parse - responsible for taking drawn value in the input (it does not matter how it turned out there) and set in value

    So in addition, to formatting what the user enters, these methods should also do the inverse transformations for each other (please check a quick example - https://snippet.webix.com/kbm3k1iq).
    These methods work when the focus changes - it checks to see if the value has changed.
    In your example, the initial value is 1, the value from the input is "1.00", and in parse the value is thrown as it is. As a result, value changes from 1 to "1.00", so onChange is triggered

  • Thank you for the answer!

  • @annazankevich
    Hello!
    I have one more question.
    Do I understand correctly that there is no way to make the behavior of simple "Text"-view similar to that in the table - when you open editor - to replace the value with another? At the moment, I can only imagine the solution with the "onfocus" listener.

    https://snippet.webix.com/hfsqq8gr

  • edited July 9

    Hello @lBeJIuk,
    You are right, here you can use onFocus or native focus events.
    The ui.datatable has other formatting rules: an editor is created at the time of opening. There is a separate editor in which/from which value is transferred, separately - a cell with what is drawn in it.
    The ui.text is one always active text field. Format is the most logical behavior for such a field. There is also a pattern (more stringent formatting), but it is not very flexible.

    The example below is not suitable in your case, however, it makes it clear that much is possible: https://snippet.webix.com/7cahssh7
    Our pattern shifts characters: from "12/03/1998" when deleting 0 it turns out "12/31/998". The code above is an attempt to solve the problem.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!