On 25/03/2010 19:59, Ken MacDonald wrote:
Hi Michael,
I have a (WPF) TextBox on a popup window. The textbox is supposed to
allow the user to enter a guest's name before clicking one of the
buttons on the popup. When the popup first appears, I want to have
some dummy text in the textbox indicating that they should put in a
name, e.g. "<Enter Name Here>". When the user clicks into the textbox,
I want to select/highlight all of the text in the textbox, and set the
text-caret at the end, so that typing anything will cause the dummy
text to disappear and leave, say, "fred". This is a behavior I've seen
on hundreds of applications, websites, etc. but it doesn't seem to
want to play with ipy.
Well, it certainly won't be a problem with IronPython. Actually in my
experience the more common behaviour is that the pre-existing text
disappears on focus not when you start typing.
I do see the same behavior as you - although I see the selection 'flash'
when the method is executed. The code is being executed, the problem is
that the standard event handling for the focus event is to unset the
selection and put the caret at the end of the textbox. Even setting
'Handled' to true on the GotFocus event doesn't override this default
behavior.
Why not just clear the textbox on focus instead? If the textbox is still
empty on LostFocus you can restore the dummy text.
Michael
Thanks,
Ken
On Thu, Mar 25, 2010 at 3:44 PM, Michael Foord
<fuzzy...@voidspace.org.uk <mailto:fuzzy...@voidspace.org.uk>> wrote:
On 25/03/2010 19:33, Ken MacDonald wrote:
On Wed, Mar 24, 2010 at 7:27 PM, Ken MacDonald
<drken...@gmail.com <mailto:drken...@gmail.com>> wrote:
Hi,
Using WPF. I'll give the Start/Length a try....
Ken
OK, I tried that in various flavors, still not working. The
selection itself appears to be working; if I un-comment the
"Cut()" at the end, I click into the box and the existing text
disappears. Without the Cut(), if I click into the box, the caret
appears at the end of the existing text, the text is NOT
highlighted (as in Ctrl-A, which works fine), and typing just
appends to the existing text. Any clues appreciated. I've been
trying to get this working for several days now, and everything
I've found seems to indicate this should work.
Hi Ken,
Can you repeat your requirements, I'll try to suggest some code.
Michael
Ken
def guest_name_keyboard_focus(self, sender, args):
print("got focus!")
textbox = self.control("NewGuestName")
#textbox.SelectAll()
textbox.Focus()
textbox.SelectionStart = 0
textbox.SelectionLength = len(textbox.Text)
#textbox.Cut() <=== works if un-commented
_______________________________________________
Users mailing list
Users@lists.ironpython.com <mailto:Users@lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
READ CAREFULLY. By accepting and reading this email you agree, on behalf of
your employer, to release me from all obligations and waivers arising from any
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap,
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in perpetuity, without
prejudice to my ongoing rights and privileges. You further represent that you
have the authority to release me from any BOGUS AGREEMENTS on behalf of your
employer.
_______________________________________________
Users mailing list
Users@lists.ironpython.com <mailto:Users@lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
READ CAREFULLY. By accepting and reading this email you agree, on behalf of
your employer, to release me from all obligations and waivers arising from any
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap,
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your
employer, its partners, licensors, agents and assigns, in perpetuity, without
prejudice to my ongoing rights and privileges. You further represent that you
have the authority to release me from any BOGUS AGREEMENTS on behalf of your
employer.
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com