Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#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)

selectOnClick.html (761 bytes) - added by Jean-Rubin Leonard 10 years ago.

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by Jean-Rubin Leonard

Attachment: selectOnClick.html added

comment:1 Changed 10 years ago by Jean-Rubin Leonard

Also i forgot: I am coding from trunk on FF 3.5.5 on mac os 10.5. JR

comment:2 Changed 10 years ago by bill

Owner: set to Douglas Hays

comment:3 Changed 10 years ago by Douglas Hays

Owner: changed from Douglas Hays to bill

stopped working with [20662]

comment:4 Changed 10 years ago by bill

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 10 years ago by Douglas Hays

Owner: changed from bill to Nathan Toone

comment:6 Changed 10 years ago by Douglas Hays

Owner: changed from Nathan Toone to bill

oops, looked at [20622] instead of [20662]

comment:7 Changed 10 years ago by bill

Resolution: fixed
Status: newclosed

[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.)

Fixes #10417, refs #10208, #8187 !strict.

comment:8 Changed 9 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.