On Thu, Dec 27, 2012 at 3:42 PM, Art Heimsoth <artst...@artheimsoth.com> wrote:

> I am trying to capture the content of an Edit field before the dialog user's
> entry character changes it.  I am using a combination of GotFocus and
> Update events - the onGotFocus method to determine when that field has
> the focus, and then the Update method to actually detect the field is being
> changed.  I am trying at that point to retrieve the field content with getText
> but want it *before* the keypress has actually changed the data.  It appears
> to always be *after* the change has been made.

Yes, the UPDATE event notification is always going to be after the
user has typed a key.  I think you should just use the GOTFOCUS event.

> I do not want to enter
> the Update method when the user is simply tabbing over the field, or
> before they attempt to entry data into it.

I don't quite understand why it makes a difference?   Each time the
edit control gets the focus, save the current text.  If the user is
simply tabbing over the edit control, so what?  The next time the user
sets focus to the edit control, save the text again.  Sure it will be
the save text you saved the previous time, but there is no down-side
to it.  It will not slow your program down or anything like that.

> Is this possible?

You would need to use the connectCharEvent() instead of connecting the
UPDATE event.  Set a flag in the got focus handler, say noCharsYet and
maybe another, didGetFocus.  In the character event handler, if
didGetFocus and noCharsYet save the edit control text; set noCharsYet
to false, and return .true always from the handler so that the
character is passed on to the edit control.  Connect the lost focus
event to change the didGetFocus flag.  Not sure if you will need all
of that or not.  Depends on exactly what you are trying to do...

> Code fragment..

-- This has to be after the underlying dialog exists:
self~new(IDC_EditFieldName1)~connectCharEvent(onCharFieldName1)

self~connectEditEvent(IDC_EditFieldName1, LOSTFOCUS, onLostFocusFieldName1)
self~connectEditEvent(IDC_EditFieldName1, GOTFOCUS, onGotFocusName1)
> ...
> ...

::method onGotFocusName1
  expose noCharsYet didGetFocus

  noCharsYet = .false
  didGetFocus = .true

::method onCharFieldName1
  expose noCharsYet didGetFocus saveTextFieldName1
  use arg char, isShift, isCtrl, isAlt, misc, editCtrl

  if didGetFocus then do
    if noCharsYet then do
      saveTextFieldName1 = editCtryl~getText
      noCharsYet = .false
    end
  end

  return .true

::method onLostFocusFieldName1
  expose didGetFocus
  didGetFocus = .false

...

That should essentially do what you are asking.  I'm not really sure
whether  the didGetFocus flag fits with what you need or not.  You
might want to play with it a bit to refine it.

--
Mark Miesfeld

------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to