[IronPython] focus and selecting text in a TextBox with IronPython
Ken MacDonald
drken567 at gmail.com
Thu Mar 25 00:27:43 CET 2010
Hi,
Using WPF. I'll give the Start/Length a try....
Ken
On Wed, Mar 24, 2010 at 6:50 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:
> Hello Ken,
>
> You don't say whether you are using WPF, Windows Forms or Silverlight. When
> I've written code similar to your with windows forms and always used
> SelectionStart and SelectionLength.
>
> All the best,
>
> Michael
>
>
> On 24/03/2010 20:54, Ken MacDonald wrote:
>
> I'm trying to capture the event of focus being shifted into a text box via
> mouse click, and would like to highlight the existing text, so that if I
> start typing the selected text will disappear. i.e. the the box initially
> contains "<Enter Name>", I click into the box, "<Enter Name>" is
> highlighted, and if I type "fred" the initial text will disappear, leaving
> only "fred". I can capture the focus with:
>
> textbox.GotKeyboardFocus += name_keyboard_focus
>
> but this handler is doing something wrong:
>
> def name_keyboard_focus(self, sender, args):
> #alert("got focus!")
> textbox = self.control("NewName")
> textbox.Focus()
> textbox.SelectAll()
>
> If I add:
>
> textbox.Cut()
>
> or:
> alert(textbox.SelectedText)
>
> at the end, it's obvious that the SelectAll() has worked, but the text is
> NOT highlighted, and if I type "fred" I get "fred" appended to the original
> text, "<Enter Name>fred".
>
> Any clues appreciated.
> Ken
>
>
> _______________________________________________
> Users mailing listUsers at lists.ironpython.comhttp://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 at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100324/016e9369/attachment.html>
More information about the Ironpython-users
mailing list