<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=windows-1252"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 25/03/2010 19:59, Ken MacDonald wrote:
<blockquote
 cite="mid:3468cae11003251259p4717bc48oa988977c3a7b7df4@mail.gmail.com"
 type="cite">Hi Michael,<br>
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. "&lt;Enter Name Here&gt;". 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.<br>
</blockquote>
<br>
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.<br>
<br>
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.<br>
<br>
Why not just clear the textbox on focus instead? If the textbox is
still empty on LostFocus you can restore the dummy text.<br>
<br>
Michael<br>
<br>
<br>
<blockquote
 cite="mid:3468cae11003251259p4717bc48oa988977c3a7b7df4@mail.gmail.com"
 type="cite">Thanks,<br>
Ken<br>
  <br>
  <div class="gmail_quote">On Thu, Mar 25, 2010 at 3:44 PM, Michael
Foord <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div text="#000000" bgcolor="#ffffff">
    <div class="im">On 25/03/2010 19:33, Ken MacDonald wrote:
    <blockquote type="cite">
      <div class="gmail_quote">On Wed, Mar 24, 2010 at 7:27 PM, Ken
MacDonald <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:drken567@gmail.com" target="_blank">drken567@gmail.com</a>&gt;</span>
wrote:<br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
Using WPF. I'll give the Start/Length a try....<br>
        <font color="#888888">Ken</font>
        <div>
        <div><br>
        </div>
        </div>
      </blockquote>
      <div>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.<br>
      </div>
      </div>
    </blockquote>
    <br>
    </div>
Hi Ken,<br>
    <br>
Can you repeat your requirements, I'll try to suggest some code.<br>
    <br>
Michael<br>
    <br>
    <blockquote type="cite">
      <div class="im">
      <div class="gmail_quote">
      <div>Ken<br>
 </div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div>
        <div>    def guest_name_keyboard_focus(self, sender,
args):<br>
        print("got focus!")<br>
        textbox = self.control("NewGuestName")<br>
        #textbox.SelectAll()<br>
        textbox.Focus()<br>
        textbox.SelectionStart = 0<br>
        textbox.SelectionLength = len(textbox.Text)<br>
        </div>
        </div>
      </blockquote>
      <div> </div>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        <div>
        <div>        #textbox.Cut()   &lt;=== works if
un-commented<br>
        <br>
        </div>
        </div>
      </blockquote>
      </div>
      </div>
      <pre><fieldset></fieldset>
_______________________________________________
Users mailing list
<div class="im"><a moz-do-not-send="true"
 href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a>
<a moz-do-not-send="true"
 href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
 target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a>
  </div></pre>
    </blockquote>
    <div class="im"><br>
    <br>
    <pre cols="72">-- 
<a moz-do-not-send="true" href="http://www.ironpythoninaction.com/"
 target="_blank">http://www.ironpythoninaction.com/</a>
<a moz-do-not-send="true" href="http://www.voidspace.org.uk/blog"
 target="_blank">http://www.voidspace.org.uk/blog</a>

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.

    </pre>
    </div>
    </div>
    <br>
_______________________________________________<br>
Users mailing list<br>
    <a moz-do-not-send="true" href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
    <a moz-do-not-send="true"
 href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
 target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
    <br>
  </blockquote>
  </div>
  <br>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>
<a class="moz-txt-link-freetext" href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a>
  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a>
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/blog">http://www.voidspace.org.uk/blog</a>

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.

</pre>
</body>
</html>