Forum: wxRuby How to deselect the text

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Кирилл Лиходедов (Guest)
on 2008-11-05 12:14
(Received via mailing list)
Hi,
I'm using TextCtrl and initially set some text in it. And all the text
is
selected by default.
How can I deselect it?
By the way, TextCtrl#set_selection() doesn't work... What am I doing
wrong?

Thanks a lot,
Kirill.

Here's the sample:

====================== wxtest.rb ===========================
require 'wx'

class TestFrame < Wx::Frame

  def initialize
    super(nil, -1, "Test")
    text = Wx::TextCtrl.new(self, -1, "first_line\n",
          :style => Wx::TE_RICH|Wx::TE_RICH2|Wx::TE_MULTILINE)
    text.append_text "second line"
    text.set_selection(3, 4)
  end

end

class TestApp < Wx::App
  def on_init
    TestFrame.new.show
  end
end

TestApp.new.main_loop
Alex F. (Guest)
on 2008-11-05 13:47
(Received via mailing list)
Кирилл Лиходедов wrote
> I'm using TextCtrl and initially set some text in it. And all the text
> is selected by default.
> How can I deselect it?
> By the way, TextCtrl#set_selection() doesn't work... What am I doing
> wrong?

Thanks for reporting this and providing a clear test case. I've tried it
out and it seems to be a bug, specific to Windows. I was a bit surprised
as I'm fairly sure this used to work.

If you're able, please could you file this on the bug tracker and attach
your example as a test case. This will be a MUSTFIX for 2.0.

By the way, if you're using RICH and RICH2 for formatting, you might see
if RichTextCtrl works better for you. TextCtrl + RICH2 has some
cross-platform quirks, although it will be better for accessibility I
guess.

thanks
alex
Kirill L. (Guest)
on 2008-11-05 14:09
(Received via mailing list)
>
>
>> Thanks for reporting this and providing a clear test case. I've tried it
> out and it seems to be a bug, specific to Windows. I was a bit surprised as
> I'm fairly sure this used to work.
>
> If you're able, please could you file this on the bug tracker and attach
> your example as a test case. This will be a MUSTFIX for 2.0.


Done:
http://rubyforge.org/tracker/index.php?func=detail...

And it also didn't work in 1.9.8, I just didn't pay attention to it at
that
time.

By the way, is it also a bug that the whole text is selected by default?

By the way, if you're using RICH and RICH2 for formatting, you might see
if
> RichTextCtrl works better for you. TextCtrl + RICH2 has some cross-platform
> quirks, although it will be better for accessibility I guess.


I'm not sure that I need all the power provided by RichTextCtrl, it
looks
that for my task simple TextCtrl is just fine. But I'll try, thanks for
pointing to it.

Regards,
Kirill.
Alex F. (Guest)
on 2008-11-05 19:14
(Received via mailing list)
Kirill L. wrote:
> Done:
> http://rubyforge.org/tracker/index.php?func=detail...
> <http://rubyforge.org/tracker/index.php?func=detail...

Thanks

> And it also didn't work in 1.9.8, I just didn't pay attention to it at
> that time.
>
> By the way, is it also a bug that the whole text is selected by default?

Yes, I think so. It doesn't do this on other platforms.

a
This topic is locked and can not be replied to.