Page 1 of 1

Retrieve and set focus

Posted: Tue Jan 19, 2016 7:57 am
by skiman
Hi,

I have the following:
Customer screen with dcsay ... GET ...
2 buttons with prev/next.

When I'm in edit mode in this screen, and my cursor is on a field, if want that the focus remains on that field after clicking the buttons for skipping.

If the cursor is on address, if want it returns on address after skipping, if the focus is on phone number, i want it back on phone numer after skipping, ...

I tried the following:

Code: Select all

   @ nRow+nBottom,5 dcpushbuttonXP notabstop BITMAP ABO_PREV1N ALIGN 4 OFFSET 3 CONFIG oConfig SIZE 10,2 CAPTION 'F1' ;
        ACCELKEY xbeK_F1 ;
        ACTION {|o| ... if(valtype(oOldfocus)="O",dc_setappfocus(oOldFocus),),dc_getrefresh(getlist) } ;
	GOTFOCUS {|| oOldFocus:=dc_setappfocus() }
The following error appears:

Code: Select all

oError:args         :
          -> VALTYPE: U VALUE: NIL
oError:canDefault   : N
oError:canRetry     : N
oError:canSubstitute: Y
oError:cargo        : NIL
oError:description  : Receiver of message is not an object.
oError:filename     : 
oError:genCode      :         38
oError:operation    : setParent
oError:osCode       :          0 
oError:severity     :          2
oError:subCode      :       2266
oError:subSystem    : BASE
oError:thread       :          3
oError:tries        :          0
Any suggestions?

Re: Retrieve and set focus

Posted: Tue Jan 19, 2016 10:06 am
by Cliff Wiernik
This is what I use if I am in edit mode and click a popup button for some reason and want to return to the last edit focus.

Code: Select all

  IF valtype(DC_EditControlLastFocus(aMainGetList))=='O'
    SetAppFocus(DC_EditControlLastFocus(aMainGetList))
  ENDIF

Re: Retrieve and set focus

Posted: Wed Jan 20, 2016 5:01 am
by skiman
Hi Cliff,

Thanks for the tip. Is working as expected. I wasn't aware of that function.

Re: Retrieve and set focus

Posted: Wed Jan 20, 2016 5:32 am
by Cliff Wiernik
Roger pointed it out to me quite a while ago.