You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2016/12/02 09:07:45 UTC

How allow select from a disabled field

The Apache Isis project [1] uses Wicket for its main viewer, and we
recently had this question [2] on our mailing list is:

I believe it was mentioned once in another thread that selecting text
(and so copying) from a disabled field doesn't work in Firefox on
Windows. Since a week or two it's not possible on a lot of Chrome
installations of our users either, probably due to a Chrome update. This
really is a big problem for our users because we share a lot of
configuration data for internet access and telephony services and
copying data makes sure they don't make mistakes while configuring their
systems.

Would it be a problem to use the read only attribute instead of the
disabled attribute? That would be an easy fix.


Martin G suggested a possible fix using CSS, but unfortunately to no
avail.  Since this presumably could impact all Wicket users, the suggestion
[3] was to re-raise the question here.

So, are there any thoughts on this?  Is there any way to enable select text
for a disabled input field for both latest Chrome and Firefox?

Thx
Dan

[1] http://isis.apache.org/
[2]
https://lists.apache.org/thread.html/354ff5bb35c3dd60fbe643f824951c9665aa7546d79562cf15e014f7@%3Cusers.isis.apache.org%3E
[3]
https://lists.apache.org/thread.html/566709f02cc6a4607d1f86d98e19ec1e7d39a2a255dc9895d5800635@%3Cusers.isis.apache.org%3E

Re: How allow select from a disabled field

Posted by Sven Meier <sv...@meiers.net>.
I just remembered that we utilized this trick⁣​ back when IE 6? used to render disabled text inputs with unreadable colors.

Sven

Am 2. Dez. 2016, 12:19, um 12:19, Sven Meier <sv...@meiers.net> schrieb:
>Hi,
>
>too bad the Firefox developers can't read a spec correctly :P
>
>https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-readonly-attribute
>"The difference between disabled and readonly is that read-only
>controls 
>are still focusable, so the user can still select the text and interact
>
>with it, whereas disabled controls are entirely non-interactive."
>
>All text on a web page is 'entirely non-interactive', nevertheless I
>can 
>still select and copy it. IMHO copying text from a disabled input 
>doesn't mean I'm interacting with it.
>
>But what's wrong with this solution:
>
>                 input.add(new Behavior() {
>                     @Override
>                     public void onComponentTag(Component component, 
>ComponentTag tag) {
>                         super.onComponentTag(component, tag);
>
>                         if (component.isEnabled() == false) {
>                             tag.remove("disabled");
>                             tag.put("readonly", "readonly");
>                         }
>                     }
>                 }));
>
>You can add this behavior to all your inputs via an 
>IComponentInstantiationListener.
>
>Regards
>Sven
>
>
>
>On 02.12.2016 10:07, Dan Haywood wrote:
>> The Apache Isis project [1] uses Wicket for its main viewer, and we
>> recently had this question [2] on our mailing list is:
>>
>> I believe it was mentioned once in another thread that selecting text
>> (and so copying) from a disabled field doesn't work in Firefox on
>> Windows. Since a week or two it's not possible on a lot of Chrome
>> installations of our users either, probably due to a Chrome update.
>This
>> really is a big problem for our users because we share a lot of
>> configuration data for internet access and telephony services and
>> copying data makes sure they don't make mistakes while configuring
>their
>> systems.
>>
>> Would it be a problem to use the read only attribute instead of the
>> disabled attribute? That would be an easy fix.
>>
>>
>> Martin G suggested a possible fix using CSS, but unfortunately to no
>> avail.  Since this presumably could impact all Wicket users, the
>suggestion
>> [3] was to re-raise the question here.
>>
>> So, are there any thoughts on this?  Is there any way to enable
>select text
>> for a disabled input field for both latest Chrome and Firefox?
>>
>> Thx
>> Dan
>>
>> [1] http://isis.apache.org/
>> [2]
>>
>https://lists.apache.org/thread.html/354ff5bb35c3dd60fbe643f824951c9665aa7546d79562cf15e014f7@%3Cusers.isis.apache.org%3E
>> [3]
>>
>https://lists.apache.org/thread.html/566709f02cc6a4607d1f86d98e19ec1e7d39a2a255dc9895d5800635@%3Cusers.isis.apache.org%3E
>>

Re: How allow select from a disabled field

Posted by Sven Meier <sv...@meiers.net>.
Hi,

too bad the Firefox developers can't read a spec correctly :P

https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-readonly-attribute
"The difference between disabled and readonly is that read-only controls 
are still focusable, so the user can still select the text and interact 
with it, whereas disabled controls are entirely non-interactive."

All text on a web page is 'entirely non-interactive', nevertheless I can 
still select and copy it. IMHO copying text from a disabled input 
doesn't mean I'm interacting with it.

But what's wrong with this solution:

                 input.add(new Behavior() {
                     @Override
                     public void onComponentTag(Component component, 
ComponentTag tag) {
                         super.onComponentTag(component, tag);

                         if (component.isEnabled() == false) {
                             tag.remove("disabled");
                             tag.put("readonly", "readonly");
                         }
                     }
                 }));

You can add this behavior to all your inputs via an 
IComponentInstantiationListener.

Regards
Sven



On 02.12.2016 10:07, Dan Haywood wrote:
> The Apache Isis project [1] uses Wicket for its main viewer, and we
> recently had this question [2] on our mailing list is:
>
> I believe it was mentioned once in another thread that selecting text
> (and so copying) from a disabled field doesn't work in Firefox on
> Windows. Since a week or two it's not possible on a lot of Chrome
> installations of our users either, probably due to a Chrome update. This
> really is a big problem for our users because we share a lot of
> configuration data for internet access and telephony services and
> copying data makes sure they don't make mistakes while configuring their
> systems.
>
> Would it be a problem to use the read only attribute instead of the
> disabled attribute? That would be an easy fix.
>
>
> Martin G suggested a possible fix using CSS, but unfortunately to no
> avail.  Since this presumably could impact all Wicket users, the suggestion
> [3] was to re-raise the question here.
>
> So, are there any thoughts on this?  Is there any way to enable select text
> for a disabled input field for both latest Chrome and Firefox?
>
> Thx
> Dan
>
> [1] http://isis.apache.org/
> [2]
> https://lists.apache.org/thread.html/354ff5bb35c3dd60fbe643f824951c9665aa7546d79562cf15e014f7@%3Cusers.isis.apache.org%3E
> [3]
> https://lists.apache.org/thread.html/566709f02cc6a4607d1f86d98e19ec1e7d39a2a255dc9895d5800635@%3Cusers.isis.apache.org%3E
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How allow select from a disabled field

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
yep, just to say that the suggestion worked.  Thx!

[1] https://issues.apache.org/jira/browse/ISIS-1552


On Sat, 3 Dec 2016 at 13:32 Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Ok, thanks... I'll try it out and report back
>
> On Sat, 3 Dec 2016, 12:02 Martin Grigorov, <mg...@apache.org> wrote:
>
> There is no need of new method to TextField (or other FormComponents).
> We already
> have org.apache.wicket.markup.html.form.FormComponent#onDisabled(), it sets
> the "disabled" attribute at the moment.
>
> Sven's suggestion to use Behavior + IComponentInstantiationListener looks
> the most flexible to me.
> @Dan: this should solve the issue for Isis.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Dec 2, 2016 at 6:03 PM, Martijn Dashorst <
> martijn.dashorst@gmail.com
> > wrote:
>
> > On Fri, Dec 2, 2016 at 12:21 PM, Pedro Santos <pe...@gmail.com>
> wrote:
> > > After reading the thread on Isis's mailing list, I'm under the
> impression
> > > that the best solution is to offer an API enabling users to configure
> how
> > > the disabled text field will be shown. My suggestion is to add the
> method
> > > TextField.showDisabledAsReadOnly(boolean) and to keep the current
> > > "disabled" attribute as the default presentation of a disabled text
> > field.
> >
> > Of course we can change the behavior in a major version such as 8.0.
> >
> > That said, changing disabled to mean readonly doesn't sound like a
> > good idea as a general rule, only if the names convey different
> > meanings.
> >
> >
> > OTOH, I doubt adding a `setReadOnly` option to TextField is a good
> > option as well.
> >
> > Martijn
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>

Re: How allow select from a disabled field

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Ok, thanks... I'll try it out and report back

On Sat, 3 Dec 2016, 12:02 Martin Grigorov, <mg...@apache.org> wrote:

> There is no need of new method to TextField (or other FormComponents).
> We already
> have org.apache.wicket.markup.html.form.FormComponent#onDisabled(), it sets
> the "disabled" attribute at the moment.
>
> Sven's suggestion to use Behavior + IComponentInstantiationListener looks
> the most flexible to me.
> @Dan: this should solve the issue for Isis.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Dec 2, 2016 at 6:03 PM, Martijn Dashorst <
> martijn.dashorst@gmail.com
> > wrote:
>
> > On Fri, Dec 2, 2016 at 12:21 PM, Pedro Santos <pe...@gmail.com>
> wrote:
> > > After reading the thread on Isis's mailing list, I'm under the
> impression
> > > that the best solution is to offer an API enabling users to configure
> how
> > > the disabled text field will be shown. My suggestion is to add the
> method
> > > TextField.showDisabledAsReadOnly(boolean) and to keep the current
> > > "disabled" attribute as the default presentation of a disabled text
> > field.
> >
> > Of course we can change the behavior in a major version such as 8.0.
> >
> > That said, changing disabled to mean readonly doesn't sound like a
> > good idea as a general rule, only if the names convey different
> > meanings.
> >
> >
> > OTOH, I doubt adding a `setReadOnly` option to TextField is a good
> > option as well.
> >
> > Martijn
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: How allow select from a disabled field

Posted by Martin Grigorov <mg...@apache.org>.
There is no need of new method to TextField (or other FormComponents).
We already
have org.apache.wicket.markup.html.form.FormComponent#onDisabled(), it sets
the "disabled" attribute at the moment.

Sven's suggestion to use Behavior + IComponentInstantiationListener looks
the most flexible to me.
@Dan: this should solve the issue for Isis.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Dec 2, 2016 at 6:03 PM, Martijn Dashorst <martijn.dashorst@gmail.com
> wrote:

> On Fri, Dec 2, 2016 at 12:21 PM, Pedro Santos <pe...@gmail.com> wrote:
> > After reading the thread on Isis's mailing list, I'm under the impression
> > that the best solution is to offer an API enabling users to configure how
> > the disabled text field will be shown. My suggestion is to add the method
> > TextField.showDisabledAsReadOnly(boolean) and to keep the current
> > "disabled" attribute as the default presentation of a disabled text
> field.
>
> Of course we can change the behavior in a major version such as 8.0.
>
> That said, changing disabled to mean readonly doesn't sound like a
> good idea as a general rule, only if the names convey different
> meanings.
>
>
> OTOH, I doubt adding a `setReadOnly` option to TextField is a good
> option as well.
>
> Martijn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How allow select from a disabled field

Posted by Martijn Dashorst <ma...@gmail.com>.
On Fri, Dec 2, 2016 at 12:21 PM, Pedro Santos <pe...@gmail.com> wrote:
> After reading the thread on Isis's mailing list, I'm under the impression
> that the best solution is to offer an API enabling users to configure how
> the disabled text field will be shown. My suggestion is to add the method
> TextField.showDisabledAsReadOnly(boolean) and to keep the current
> "disabled" attribute as the default presentation of a disabled text field.

Of course we can change the behavior in a major version such as 8.0.

That said, changing disabled to mean readonly doesn't sound like a
good idea as a general rule, only if the names convey different
meanings.


OTOH, I doubt adding a `setReadOnly` option to TextField is a good
option as well.

Martijn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How allow select from a disabled field

Posted by Pedro Santos <pe...@gmail.com>.
After reading the thread on Isis's mailing list, I'm under the impression
that the best solution is to offer an API enabling users to configure how
the disabled text field will be shown. My suggestion is to add the method
TextField.showDisabledAsReadOnly(boolean) and to keep the current
"disabled" attribute as the default presentation of a disabled text field.

Cheers


Pedro Santos

On Fri, Dec 2, 2016 at 7:07 AM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> The Apache Isis project [1] uses Wicket for its main viewer, and we
> recently had this question [2] on our mailing list is:
>
> I believe it was mentioned once in another thread that selecting text
> (and so copying) from a disabled field doesn't work in Firefox on
> Windows. Since a week or two it's not possible on a lot of Chrome
> installations of our users either, probably due to a Chrome update. This
> really is a big problem for our users because we share a lot of
> configuration data for internet access and telephony services and
> copying data makes sure they don't make mistakes while configuring their
> systems.
>
> Would it be a problem to use the read only attribute instead of the
> disabled attribute? That would be an easy fix.
>
>
> Martin G suggested a possible fix using CSS, but unfortunately to no
> avail.  Since this presumably could impact all Wicket users, the suggestion
> [3] was to re-raise the question here.
>
> So, are there any thoughts on this?  Is there any way to enable select text
> for a disabled input field for both latest Chrome and Firefox?
>
> Thx
> Dan
>
> [1] http://isis.apache.org/
> [2]
> https://lists.apache.org/thread.html/354ff5bb35c3dd60fbe643f824951c
> 9665aa7546d79562cf15e014f7@%3Cusers.isis.apache.org%3E
> [3]
> https://lists.apache.org/thread.html/566709f02cc6a4607d1f86d98e19ec
> 1e7d39a2a255dc9895d5800635@%3Cusers.isis.apache.org%3E
>