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

  • From: pulkomandy <pulkomandy@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 1 Oct 2014 13:28:22 +0200

On Wed, Oct 01, 2014 at 11:25:00PM +1300, Richie Nyhus wrote:
> Are native date/time spinners something that could help to decrease the
> chances of users getting confused?
> 
> Some examples of optional and non optional date spinners:
> 
> http://jdewit.github.io/bootstrap-timepicker/
> http://www.jqueryscript.net/demo/Minimal-jQuery-Time-Picker-Plugin-with-jQuery-TimePicki/
> http://eonasdan.github.io/bootstrap-datetimepicker/#example4

We don't have native spinners, currently. I find the way they are
implemented on other systems to be rather bad (with two very small
buttons to increase and decrease the value, too small for practical
use). I found that I never use those small buttons, and end up entering
the value manually using the keyboard, and using a BTextControl for that
sounds fine.

For bounded inputs (for example the month, only 12 possible values), I
use a BMenuField, which works much better and allow to reach any month
in just two clicks. I plan to experiment with making it
increase/decrease on mouse wheel events as well.

The current WIP of the time picker for WebKit also uses BMenuFields for
the hour and minutes, however this is not as good as the menus are too
big (24 and 60 entries respectively), especially if shown in the usual
single-column layout. The mouse wheel solution still applies, and I
think by using a B_ITEMS_IN_MATRIX menu we can bring them to a more
reasonable and easily navigable size. I will experiment further with
this.

This leaves open the problem of picking a year. There are no bounds on
the choices you can make there, so a popup menu isn't suitable. This is
why I went with a BTextControl with input validation. I can also add
mouse wheel increase/decrease support (or keyboard up/down), making this
behave very similar to a spinner, but without the useless buttons. Or
bigger buttons could be used, as is done in the Screen preferences
workspace count adjust (note that this one does allow entering
non-digits in the field, currently, and should also be fixed).

The choice of using a spinner is orthogonal to the issue anyway. We
still need to decide wether we want to allow the control to accept
non-digit values, but mark them as invalid, or if we want to deny
keyboard input and emit a beep (which may be missed for reasons Stephan
already mentionned).

I should add that marking invalid controls has uses outside of the
problem of entering numbers. For example in one app I'm working on, I have
a field where the user can enter a complex expression, and I'd need to
notify problems (for example unmatched parentheses) without preventing
keystrokes. For an example of this in an existing  real-world app, have
a look at Wireshark filtering field.

In hrev47939 I have implemented the invalid marking for BTextControl.
There is a test app showcasing what it looks like in
tests/kits/interface/TestViewTestManual.cpp (jam TextViewTest).

I think this approach has better user experience. Instead of a beep
that, if you hear it at all, does not bring much information, you can
see:
* What you typed,
* Which fields are wrong,
* And with a tooltip over them (for example), why they are wrong.

This makes the UI more self-explanatory, and you don't have to reach out
for the software user manual to see that the fields accepts "only
digits", "any valid numer including hexadecimal", or "a valid regular
expression". You can try typing things and see how the software behaves
instead.

-- 
Adrien.

Other related posts: