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

Revamp event handling in text boxes and add continuous_update option #1545

Merged
merged 11 commits into from
Jul 31, 2017

Conversation

jasongrout
Copy link
Member

@jasongrout jasongrout commented Jul 27, 2017

  • Check the width of float/int/bounded text boxes now - they seem to be shorter.
  • deprecate the on_submit handler for text boxes, and handle the events similar to how things are done in this PR (with input and change events).

Also, specialize those inputs to type number, and add a step option.

I default continuous_update to False for the textboxes because I figured if people were typing, that's typically what is wanted.

FIxes #584 and #1401.

…e with sliders.

This also is needed to make the spinners in the new number inputs work appropriately, especially with floating point numbers.
@jasongrout
Copy link
Member Author

CC @mpacer

@jasongrout
Copy link
Member Author

@mpacer (or anyone), if you have a better name than "continuous_update", I'm all ears...

Deprecate the Text on_submit handler.
Basically, if you typed ‘3.’, it would parse the number as 3 and reset the value, so you could never type the decimal.

Also, fixed some issues with min, max, and step being set, especially if they were undefined.
For floats, a step of None means any step is allowed.
@jasongrout
Copy link
Member Author

@mpacer, I think this is ready to go. Would you like to give it a spin before merging, or would it be easier to merge and spin off another beta for you to take a look at?

@mpacer
Copy link
Contributor

mpacer commented Jul 27, 2017

I can give it a spin before the end of the day :) thanks for getting to this so quickly!

@jasongrout jasongrout changed the title Add continuous_update option to int/float text boxes Revamp event handling in text boxes and add continuous_update option Jul 27, 2017
@mpacer
Copy link
Contributor

mpacer commented Jul 27, 2017

I think it would help to include in the docstrings what the default behaviour is (i.e., when continuous_update is set to False). E.g., does it send when either you hit enter/return or change focus as asked for in #584?

@mpacer
Copy link
Contributor

mpacer commented Jul 27, 2017

Also it'd be good to have an example in the docs of both kinds of behaviour. Probably in the Widgets Event section. This shouldn't need backend connections as far as I can tell so it should explain the behaviour nicely in the docs with two appropriate examples.

Also, you probably want to remove the Special Events on_submit section from the docs if it's deprecated.

@mpacer
Copy link
Contributor

mpacer commented Jul 27, 2017

So this almost works, but there is bug in the continuous_update version of this if you select text and then delete it (rather than just deleting single characters):

widget_ct_up_del

@jasongrout
Copy link
Member Author

So this almost works,

I'm entirely relying on the browser events, hoping that they Do The Right Thing [1]. Does it have the behavior in other browsers too?

[1] Perhaps too optimistic? Our hopes have been dashed many times before...

@jasongrout
Copy link
Member Author

Oh, the issue there is that when you delete, it recognizes it's not a number, so it's patiently waiting for you to type something that is a number.

@jasongrout
Copy link
Member Author

(that's also why it resets when you click out - if the value is not valid, it resets to the previous value)

@jasongrout
Copy link
Member Author

Also, you probably want to remove the Special Events on_submit section from the docs if it's deprecated.

Right - doc changes coming up...

@jasongrout
Copy link
Member Author

Oh, the issue there is that when you delete, it recognizes it's not a number, so it's patiently waiting for you to type something that is a number.

What if we put in a placeholder like "Type a number" or something? That would show if you deleted everything in the box. Would that be enough of a hint?

@jasongrout
Copy link
Member Author

@mpacer, I updated the docs. Thoughts?

@jasongrout jasongrout merged commit d9e3f23 into jupyter-widgets:master Jul 31, 2017
@jasongrout
Copy link
Member Author

Merging - @mpacer, feel free to open another issue if you see something we missed.

@jasongrout jasongrout modified the milestone: 7.0 Aug 1, 2017
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a continuous_update option for text widgets
2 participants