PDA

View Full Version : [FIXED] New setEnabled(false) issues



DarekKay
11 Jan 2012, 4:02 AM
Besides my reported bug (http://www.sencha.com/forum/showthread.php?157942-FNR-Grid.setEnabled%28false%29&p=695374&viewfull=1#post695374) which you may have overseen, I found another problem: a disabled TextField is rendered gray, but you can still edit the field itself. Is that a desired behaviour? In my opinion you should not be able to edit a disabled component (it's disabled after all).
Of course I could add setEditable(false), but I would expect this as a standard behaviour (why would anyone want to disable a component and still be able to edit it).

Here a simple code:


public void onModuleLoad()
{

VerticalLayoutContainer cp = new VerticalLayoutContainer();
TextField textField1 = new TextField();
textField1.setEnabled(false);
cp.add(textField1, new VerticalLayoutData(1, -1));

ContentPanel con = new ContentPanel();
con.setSize("300px", "100px");
con.add(cp);
RootLayoutPanel.get().add(con);
}

FEAT
24 Jan 2012, 4:20 AM
As gishmo pointed out:

"All form widgets are editable if setEnable(false) ist set. Now you have to use setReadOnly(true) to lock a field. This behavior is different to the GWT standard behavior."

This solution worked for me :)

gishmo
24 Jan 2012, 4:52 AM
yep, but i personally prefer the standard behavior. ;)

DarekKay
26 Jan 2012, 12:31 AM
Isn't this exactly the thing you wanted to avoid in GXT 3? GXT 2 had many many things different from the standard GWT behavior (also many method names differed). You obviously found out that it's causing more problems than actually solving them, so GXT 3 appears to me a lot more GWT related - which is great.

So why a different behavior here? I still can't imagine, why anyone would ever want to disable a field but leave it editable. If you only want to give users the opportunity to give the field a gray style, then "disable" is a really bad description for it, since it doesn't get disabled at all. It would be great, if you'd look into that.

But nevertheless - thanks for the solution!

gishmo
28 Jan 2012, 2:27 AM
I agree and for the time without a statement from Sencha I override the ValueBaseField class in the package com.sencha.gxt.widget.core.client.form and created there a method setEnable(enabled) which looks like that:



@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
this.setReadOnly(!enabled);
}

This works for me.

gishmo
17 Feb 2012, 1:52 AM
In beta 3 setEnabled works as it does in beta 2. The read only state is not set. So you have to set the readonly state by hand ...

WesleyMoy
17 Feb 2012, 1:01 PM
Thanks for pointing this out. I've filed a ticket with the team, and I'll update this thread with any changes we plan to make to setEnabled.

gishmo
2 Mar 2012, 10:04 AM
Works as expected for TextField and TextArea in beta 4!

But, if you have a disabled ComboBox, the value list is displayed if you click the drop down button.

Tested with FF 10 and Chrome on OS X.

32331

WesleyMoy
2 Mar 2012, 10:53 AM
Thanks for testing this out with beta 4 so soon, and I'm glad to hear that your original problem has been fixed. I'll go ahead and close out the original issue. I'll file a new one for the disabled combo box's trigger showing the drop down menu.

Issue has been added as EXTGWT-1528.

darrellmeyer
19 Mar 2012, 10:58 AM
ComboBox bug is now fixed in SVN (rev 2423). Clicking on trigger of disabled combo does not show drop down.

WesleyMoy
28 Mar 2012, 2:25 PM
The remaining combo box bug has been fixed in the Ext GWT 3.0 Release Candidate. Please upgrade your copy of Ext GWT and try your test case again. While we're confident that we've addressed this entire issue, please reply if you notice any continued problems with combo box or with setEnabled after upgrading. Again, thanks for taking the time to report, investigate, and discuss this bug.

DarekKay
29 Mar 2012, 5:04 AM
It's working as expected in RC, thanks!

But there is still an issue you may have overseen: key handler are still fired. So for example take a TextField, add a KeyPressHandler and disable it. You can't really type anything (as expected), but the event is still fired. I'm not really sure about that behaviour.

darrellmeyer
30 Mar 2012, 12:25 PM
I am not sure I understand. If you disable a field you can't focus the input element and therefore no key events are fired.


public void onModuleLoad() {
VerticalLayoutContainer cp = new VerticalLayoutContainer();
TextField textField1 = new TextField();
textField1.setEnabled(false);
textField1.addKeyPressHandler(new KeyPressHandler() {

@Override
public void onKeyPress(KeyPressEvent event) {
System.out.println("key press");
}
});
cp.add(textField1, new VerticalLayoutData(1, -1));


ContentPanel con = new ContentPanel();
con.setSize("300px", "100px");
con.add(cp);
RootLayoutPanel.get().add(con);
}


What is the use case you are getting key events? Can you provide a test case?