[racket] text-field% isn't just for string input, but for output and numbers too!

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 30 13:08:01 EST 2012

A note on alignment:

The `text%' class supports 'right and 'center paragraph alignment,
which more or less works when the editor has a maximum width. (The docs
have some caveats.)

So, you can get right-alignment to a useful degree with a sequence like
this:

 (define tf (new text-field% ....))

 ;; Make the editor have a maximum width:
 (send (send tf get-editor) auto-wrap #t)
 ;; Keep the caret visible:
 (send (send tf get-editor) set-padding 0 0 2 0)
 ;; Right-align the first paragraph:
 (send (send tf get-editor) set-paragraph-alignment 0 'right)

I noticed that refresh wasn't right when editing right-aligned text,
though, and I pushed a fix for that.


At Mon, 30 Jan 2012 10:08:22 -0500, Matthias Felleisen wrote:
> 
> May I propose an experiment? While I think that this is a 
> perfectly legitimate request, I am also wondering whether 
> Matthew's port of the GUI library to Racket has improved 
> our user's ability to look at the code and to propose a 
> fix. You might consider posting it here for discussion first
> before you submit the code as a request [*].
> 
> -- Matthias
> 
> 
> [*] If you are comfortable with GIT, you may wish to send in 
> a git pull request or a git diff.
> 
> 
> 
> On Jan 30, 2012, at 9:26 AM, Marijn wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Hi,
> > 
> > when you disable a text-field% `tf' (send tf enable #f), the label is
> > greyed out and the field part doesn't accept the cursor or any other
> > form of user input. This is useful when you need an input field which
> > should not always be available.
> > When you want to use a text-field for output instead, you also want it
> > to ignore user input, but having the label greyed out isn't optimal.
> > Instead I think that it would be more intuitive if the label is left
> > as is and the field is instead given a grey background or grey border
> > or something like that. Could an option to disable user input be added
> > and another option to change the field in a manner suggesting it is
> > not accepting input?
> > 
> > A text-field% that is used for number input or number output should
> > ideally display its contents in a right-aligned manner. Would it be
> > possible to add such a (style?) option?
> > 
> > Marijn
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v2.0.18 (GNU/Linux)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> > 
> > iEYEARECAAYFAk8mqJcACgkQp/VmCx0OL2zA2gCgjMdZfKE79E2sLEy+Q+16Rbj/
> > 61AAoJDWu/xP7JLuIzCP2dhvs8NFp8l0
> > =7nSQ
> > -----END PGP SIGNATURE-----
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.