best way to left aligning text?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

best way to left aligning text?

Theo Pronk
Hi,

I am using text presenters to display a FROM and TO range. Both are only
big enough to show about 10 characters/digits. Say I enter 20 characters
and press tab it show OK (ie left aligned as the view was set).

The problem is that if I tab over the field again the selection picks
the entire string and the result is it becomes RIGHT aligned!

My solution after some experimenting is:

createSchematicWiring
   super createSchematicWiring.
   fromPresenter when: #focusLost send: #forceChangedFrom to: self.
   toPresenter when: #focusLost send: #forceChangedTo to: self.

forceChangedFrom
  fromPresenter view selectionRange: (1 to: 1)

forceChangedTo
  toPresenter view selectionRange: (1 to: 1)


This works fine but I'm sure there is a better (ie correct) way, can
anyone let me know what it is?

Thanks heaps.
Theo Pronk


Reply | Threaded
Open this post in threaded view
|

Re: best way to left aligning text?

Ian Bartholomew-18
Theo,

> This works fine but I'm sure there is a better (ie correct) way, can
> anyone let me know what it is?

I don't recall seeing a way of changing the controls default behaviour,
and a quick trawl through the TextEdit control documentation on MSDN
didn't come up with anything obvious, so I guess your method is as good
as any. You could refactor it a bit, pass the presenter as an argument
so that you only need one additional method, or even do away with the
extra method completely....

createSchematicWiring
...
    fromPresenter
        when: #focusLost
        send: #selectionRange:
        to: fromPresenter
        with: (1 to: 1).
    toPresenter
        ....&etc

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.