wxRuby2-preview: strange event of TextCtrl

...
evt_text(TEXTCTRL_ID){
  puts self.get_value
}
...

When I input "Hello",
output:
H
He
Hel
Hell
Hello

When I select "ello",and input "i"
output:
H
Hi

How can I ignore the event outputs "H"?

···

--
Posted via http://www.ruby-forum.com/.

Kuang Dong wrote:

..
evt_text(TEXTCTRL_ID){
  puts self.get_value
}
..

When I input "Hello",
output:
H
He
Hel
Hell
Hello

When I select "ello",and input "i"
output:
H
Hi

How can I ignore the event outputs "H"?

You have to choose which text events you want to act on. You are presently
acting on each entered character. I *think* you want to act only on enter
being pressed.

···

--
Paul Lutus
http://www.arachnoid.com

Hi

Kuang Dong wrote:

..
evt_text(TEXTCTRL_ID){
  puts self.get_value
}
..
When I input "Hello",

...

When I select "ello",and input "i"
output:
H
Hi

I don't see this behaviour. If I type in 'Hello', then select 'ello' and overtype with 'i', get_value in the event handler returns 'Hi'.

How can I ignore the event outputs "H"?

Are you looking for event.veto?

evt_text(the_id) { | event | event.veto }

alex

Paul Lutus wrote:

Kuang Dong wrote:

He
Hel
Hell
Hello

When I select "ello",and input "i"
output:
H
Hi

How can I ignore the event outputs "H"?

You have to choose which text events you want to act on. You are
presently
acting on each entered character. I *think* you want to act only on
enter
being pressed.

Acutally,I wanted to do something like google suggest
(Google)

When I select "ello" of "Hello" and press "i",two "text change event"
raised,one is Hello->H and the other is H->Hi.Now I have to ignore the
first event(do nothing),and give suggestion by the last word.I have no
idea.

···

--
Posted via http://www.ruby-forum.com/\.

Kuang Dong wrote:

/ ...

When I select "ello" of "Hello" and press "i",two "text change event"
raised,one is Hello->H and the other is H->Hi.Now I have to ignore the
first event(do nothing),and give suggestion by the last word.I have no
idea.

I really do not understand the problem you are having, apart from the fact
that you are writing a completion engine.

A completion engine is very easy to write, but the user has to enter the
first characters correctly.

···

------------------------------------------

#!/usr/bin/ruby

dictionary = File.read("/usr/share/dict/words")

test = "zeal"

matches = dictionary.scan(/^#{test}.*$/)

puts matches

------------------------------------------

(surprisingly long list of words whose first characters match the test
string)

Maybe you could explain the problem by saying very clearly what you hoped to
accomplish, and, equally clearly, what happened instead.

--
Paul Lutus
http://www.arachnoid.com