TextCtrl text alignment

As shown in the attached program, the text "My Long Textbox Value "in
the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32
bit, SP3)

Any help with this would be appreciated.

Thanks,

Nick G.

Hi Nick

Nicholas Gunther wrote:

As shown in the attached program, the text "My Long Textbox Value "in
the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32
bit, SP3)

I see what you mean - even if only the TextCtrl is present (it always
helps to reduce your example to as simple as possible to isolate the
problem).

I think this is just a ‘feature’ of the underlying Windows toolkit - it
always selects the first widget in a new frame when it’s shown, and when
selecting a TextCtrl, selects all the text in there. Why it scrolls a
bit horizontally I don’t know. But you could mitigate this by calling

text_ctrl.set_selection_point(0)
text_ctrl.set_selection_point_end

after the call to show()

btw, a couple of things you can write more tersely in wxRuby code:

@my_label = StaticText.new(@my_panel, -1, ‘My Label Text’,
DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER)

better as:

@my_label = StaticText.new(@my_panel, :label => ‘My Label Text’, :style
=> ALIGN_CENTRE)

evt_button(@my_button.get_id()) { |event| my_button_click(event)}

better as:

evt_button @my_button, :my_button_click

hth
alex

Well, that is helpful, although I think perhaps you meant:
set_INSERTION_point(0), not “set_selection_point”. :slight_smile:
BUT point(0), point(1), point(2), point(3), point(4) all produce the
same good outcome - the text aligned exactly flush with the left margin,
while “set_insertion_point(5)” reproduces the original problem in which
the text is scrolled to the left and the first characters that appear
are “ong” from “Long…” I note that the comboBox is text is perfectly
aligned, exactly one space from the far left margin.
You did solve the problem, for which I am grateful, but do you know why
set_insertion_point is behaving like this? Is it because in the
underlying Windows toolkit the earlier insertion points ((i) with i<5)
prevent the horizontal scrolling, but a later insertion point permits
it? I suppose so.
How odd!
Thanks again,
Nick

Alex F. wrote:

Hi Nick

Nicholas Gunther wrote:

As shown in the attached program, the text "My Long Textbox Value "in
the TextCtrl object, @my_textbox, aligns off the screen in Windos XP (32
bit, SP3)

I see what you mean - even if only the TextCtrl is present (it always
helps to reduce your example to as simple as possible to isolate the
problem).

I think this is just a ‘feature’ of the underlying Windows toolkit - it
always selects the first widget in a new frame when it’s shown, and when
selecting a TextCtrl, selects all the text in there. Why it scrolls a
bit horizontally I don’t know. But you could mitigate this by calling

text_ctrl.set_selection_point(0)
text_ctrl.set_selection_point_end

after the call to show()

btw, a couple of things you can write more tersely in wxRuby code:

@my_label = StaticText.new(@my_panel, -1, ‘My Label Text’,
DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER)

better as:

@my_label = StaticText.new(@my_panel, :label => ‘My Label Text’, :style
=> ALIGN_CENTRE)

evt_button(@my_button.get_id()) { |event| my_button_click(event)}

better as:

evt_button @my_button, :my_button_click

hth
alex