1 Feb 11:04
Re: text-field% isn't just for string input, but for output and numbers too!
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
RSS Feed