#10417 closed defect (fixed)
selectOnClick does not select textbox's text
Reported by: | Jean-Rubin Leonard | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Dijit - Form | Version: | 1.4.0b |
Keywords: | dijit textbox selectOnClick | Cc: | |
Blocked By: | Blocking: |
Description
The selectOnClick does not do what it's supposed to do. The text is not selected upon cllicking on the textbox. The problem seems to be at line 205 of form/textbox as the private property this._selectOnUp is always false. The code inside the if is therefore not executed. In my troubleshooting i forced it to true and the text was selected fine. Attached test case. Thanks for correcting. JR
Attachments (1)
Change History (9)
Changed 11 years ago by
Attachment: | selectOnClick.html added |
---|
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Owner: | set to Douglas Hays |
---|
comment:3 Changed 11 years ago by
Owner: | changed from Douglas Hays to bill |
---|
stopped working with [20662]
comment:4 Changed 11 years ago by
The "selectOnClick" feature only selects when a click brings the TextBox into focus. That's important because the user needs to be able to de-select all the text by clicking again. And also, since tabbing into the field selects all the text, it's important to be able to de-select all the text after tabbing via clicking.
The current TextBox code has an _onMouseDown handler that tries to check if the mouse down is going to focus the TextBox. Only in that case will it respond to a subsequent onClick event:
_onMouseDown: function(){ // flag if everything should be selected on mouse click // don't actually select here in case they're selecting specific text with the mouse this._selectOnUp = !this._focused && !this.disabled && !this.readOnly; },
The this._focused flag actually gets set during mouse-down, but since [20622] it's getting set right before _onMouseDown() is called, rather than right after. Hence the problem.
Note that we can't select the text on the _onFocus() event or onMouseDown() event because that event is followed by a mouse-up, which deselects all the text. Can't select the text until the mouse-up has happened.
comment:5 Changed 11 years ago by
Owner: | changed from bill to Nathan Toone |
---|
comment:6 Changed 11 years ago by
Owner: | changed from Nathan Toone to bill |
---|
comment:7 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
[In [20920]) Rework selectOnClick code to get it working again. The trick is getting it to only select all the text on the first click. (Otherwise there would be no way to deselect the text.)
Since mousedown on a blurred field focuses it, it's tricky timing detecting when the mousedown causes focus versus when the field was already focused. (Plus detecting when a focus event was caused by tabbing into the field.) Note that the order of onmousedown and onfocus varies between IE and FF.
Seems possible to detect it though, in focus.js, after [20662]. So added a flag to _onFocus() callback that tells whether focus was caused by mousedown ("mouse") or not. (Using a string flag for possible future expansion via touch events etc.)
comment:8 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
Also i forgot: I am coding from trunk on FF 3.5.5 on mac os 10.5. JR