.
contact contact

How to restore the focus to an edittext after the dialog has been made invisible?

 
.
 

Title: How to restore the focus to an edittext after the dialog has been made invisible?
Document: 915642178
Author: Roland Genske <rhg@marxmeier.com>
Keywords: windows,dlg,set,focus,visible


When I hide a dialog using DLG SET ".visible",0 and later make it visible again using DLG DO, the focus is set to the first edittext in the dialog.

How can I automatically set the focus to the edittext which had the focus before the dialog has been hidden?

This can be achieved using an user-defined attriute along with two rules. If you work with modules, changes apply only to the central module which contains the default definitions and rules. Otherwise, these changes should be applied to any of your .idm files:

   default window
   {
      ...
      object EqLastFocus := null;
   }
   ...
   on EDITTEXT select
   {
      this.window.EqLastFocus := this;
   }
   ...
   on WINDOW activate after
   {
      if (this.EqLastFocus <> null) then
         if (this.focus <> this.EqLastFocus) then
            this.EqLastFocus.focus := true;
         endif
      endif
   }

In this approach, every window object contains an user-defined attribute EqLastFocus which holds the last focused edittext object if any. The last focused edittext object is saved on entry ('select' rule above).

Whenever a window is activated (which implicitely happens if it is made visible), EqLastFocus is checked if it has been set to anything different from the currently focused object. If this is the case, the focus is set to the object referred by EqLastFocus.

 
 
.
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision:   
  Copyright © 1995-2002 Marxmeier Software AG