[racket] text-field% isn't just for string input, but for output and numbers too!
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 30-01-12 19:08, Matthew Flatt wrote:
> 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.
Thanks Matthew, that seems to work well enough; at least when some
more bugs are squished. It seems that alignment goes back to
left-aligned under certain edits. For example if I have a text-field
with an initial value of 0 and replace that 0 by anything else it gets
left-aligned.
Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAk8pDjQACgkQp/VmCx0OL2wvvQCdHHCp56ZdXivrAJzOF40yi6b3
T20AmKiEHZuGsAkE92vD04BaoDYQRYU=
=b7bv
-----END PGP SIGNATURE-----