[haiku-development] Re: RFC: B_INVALID flag for BControlLook

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 01 Oct 2014 11:48:18 +0200

Am 01.10.2014 11:07, schrieb Axel Dörfler:
Am 01.10.2014 09:34, schrieb pulkomandy:
At first I thought of filtering input to my text field to allow only
digits. This is rather difficult to implement, as we only have support
for excluding characters from the allowed input range of a BTextView.
Moreover, I now think this is a bad idea, because it leads to rejecting
user input without any feedback, and will look like the field is not
accepting input at all.
[...]
I would introduce a B_INVALID flag in BControlLook (alongside B_FOCUSED,
B_CLICKED, etc.). The flag would trigger using the B_FAILURE_COLOR for
the border as described above. It will be used mainly on BTextControl,
which is the only control accepting freeform input from the keyboard.
 >
 > Does that sound like a good way to handle the problem? Or do you have
 > better recommandations on this?

While I agree with Stephan that such a flag could be handy, I don't
think it's the best solution to the problem.

Having controls that only accept digits is pretty standard after all,
and is found pretty much everywhere else in such situations. You have a
cursor that blinks in that control. You hear a beep sound when you type
invalid characters. What more do you want? Of course, a tool tip could
be shown in that case, too, but I don't really think that would be
necessary.
I don't think a red text would be that much more helpful in any way either.

However, I also agree that it's a pain to implement this with our
current BTextView API. And I think that's something that you might want
to look into instead :-)
Something like SetKeyFilter() with a hook that returns a bool.

First of all, there are problems with preventing letters to be typed. The beep might not be audible for a number of reasons (no sound driver, user is deaf, ...). I think it should only be used where the user already expects letters to be ignored, like in a control which for obvious reasons only accepts digits (a number input).

Second, the reason why input is invalid may have nothing to do with what letters are typed. The input may be invalid because a password is required to contain at least one upper-case letter and at least one number. Or in Adrien's case, the typed date may simply be invalid.

Indicating this with a red border is pretty helpful as it is. (The user may easily spot the error herself, as long as there is a hint that there is an error.) Dynamically showing a warning text giving the specific reason is even better.

Last but not least, a red border could also indicate that a field may not be left blank.

These are all situation which cannot be solved by restricting the symbols that can be typed.

Best regards,
-Stephan


Other related posts: