Find previous focus.

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Find previous focus.

#1 Post by jdsoft »

Hello,

Here i am again...
There are 2 dialogs. (seperate thread, not the same GetList)
1 dialog contains Dc_Xbpget's
Another dialog contains only pushbuttons (keyboard) ALWAYSONTOP.
The input focus is on any Dc_Xbpget (can be any of many)

If i click on a button in the 2nd dialog then:
1. The first dialog goes out of focus.
2. The input field goes out of focus.
3. My 2nd window gets focus.
4. My pushbutton ACTION is executed.

In my pushbutton ACTION i want to send a key (for example a "A") to the Dc_Xbpget that had the previous focus (in the other dialog), and set focus to that Dc_Xbpget. If possible, without flickering......

Is the someone that has an ingenious solution for this.

Regards,
Jack Duijf.

P.s. My goal is to have a generic touchscreen keyboard for any of the dialogs in my application.
Regards,
Jack Duijf

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Find previous focus.

#2 Post by rdonnay »

Jack -

I added some new code to _DCCLASS.PRG to make this possible.

Here is what you need to do:

1. Add the following 3 lines of code to the DC_XbaseParts:setOrig() method just before the return.

Code: Select all

IF _IsEditControl(oXbp)
  oXbp:setInputFocus := DC_MergeBlocks(oXbp:setInputFocus,{||DC_LastInputFocus(oXbp)})
ENDIF
2. Add the following new functions to _DCCLASS.PRG:

Code: Select all

FUNCTION DC_LastInputFocus( oXbp )

STATIC soFocus := nil

IF Valtype(oXbp) == 'O'
  soFocus := oXbp
ENDIF

RETURN soFocus

* -------------

STATIC FUNCTION _IsEditControl( oXbp )

IF Valtype(oXbp) # 'O'
  RETURN .f.
ENDIF

RETURN oXbp:isDerivedFrom('DC_XbpGet') .OR. ;
       oXbp:isDerivedFrom('DC_XbpSle') .OR. ;
       oXbp:isDerivedFrom('DC_XbpRadioButton') .OR. ;
       oXbp:isDerivedFrom('DC_XbpComboBox') .OR. ;
       oXbp:isDerivedFrom('DC_XbpListBox') .OR. ;
       oXbp:isDerivedFrom('DC_XbpCheckBox') .OR. ;
       oXbp:isDerivedFrom('DC_XbpSpinButton') .OR. ;
       oXbp:isDerivedFrom('DC_XbpMle') .OR. ;
       oXbp:isDerivedFrom('DC_Xbp3State')

Now here is the test code I used:

Code: Select all

#INCLUDE "dcdialog.ch"
#INCLUDE "appevent.CH"

FUNCTION Main()

LOCAL GetList[0], aGets[10], i

AFill( aGets,Space(10) )

FOR i := 1 TO Len(aGets)
  @ i,1 DCGET aGets[i]
NEXT

DCREAD GUI FIT SETAPPWINDOW ;
   EVAL {|oDlg,oThread|oThread := Thread():new(), Sleep(5), oThread:start({||Keyboard()})}
            
RETURN nil

* ----------

PROC appsys ; RETURN

* ----------

FUNCTION Keyboard()

LOCAL GetList[0], i, nCol := 0

FOR i := 65 TO 65+25
  nCol += 3
  @ 0,nCol DCPUSHBUTTON CAPTION Chr(i) SIZE 3 ;
      ACTION ActionBlock(i)
NEXT

DCREAD GUI FIT TITLE 'Keyboard'

RETURN nil

* ----------

STATIC FUNCTION ActionBlock( i )

RETURN {|o| o := DC_LastInputFocus(), o:keyboard(i), o:getData() }
The eXpress train is coming - and it has more cars.

User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: Find previous focus.

#3 Post by jdsoft »

Hello Roger,

Thank you, this does almost the things i want.
This is a huge step forward. I need to fiddle a bit with my code get get it right.

Regards,
Jack Duijf
Regards,
Jack Duijf

User avatar
hz_scotty
Posts: 107
Joined: Thu Jan 28, 2010 8:20 am
Location: Wr.Neustadt / Österreich

Re: Find previous focus.

#4 Post by hz_scotty »

hello Roger!

Can you please post the new/changed _DCCLASS.PRG
(there are several place where the changes must be made)

thanks
best regards
Hans

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: Find previous focus.

#5 Post by Zdeno Bielik »

Hi Roger,

please, can you also add any method/function for saving and then restoring position in GET when loosing focus and restoring focus from another running thread/window or apps when it was selected via Alt+Tab or from TaskBar, Desktop etc.

Regards
Zdeno

s pozdravom

zdeno bielik
ace system, spol. s r.o.
štiavnická 18
949 01 nitra
http://www.acesystem.sk
tel: 0904 – 328 888
... s nami dostávate vždy viac

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Find previous focus.

#6 Post by rdonnay »

please, can you also add any method/function for saving and then restoring position in GET when loosing focus and restoring focus from another running thread/window or apps when it was selected via Alt+Tab or from TaskBar, Desktop etc.
That feature was put into eXpress++ several years ago.
It automatically restores focus to the last object that had focus when clicking back on the parent window.
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Find previous focus.

#7 Post by rdonnay »

Can you please post the new/changed _DCCLASS.PRG
File is attached.
Attachments
_dcclass.zip
(38.45 KiB) Downloaded 722 times
The eXpress train is coming - and it has more cars.

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: Find previous focus.

#8 Post by Zdeno Bielik »

rdonnay wrote:
position in GET

It automatically restores focus to the last object that had focus when clicking back on the parent window.
Roger,

yes, previosly last active get object is restored and focus is set on it, but cursor is always set on first position instead of that, what position was when object did lost focus.

Zdeno

s pozdravom

zdeno bielik
ace system, spol. s r.o.
štiavnická 18
949 01 nitra
http://www.acesystem.sk
tel: 0904 – 328 888
... s nami dostávate vždy viac

Post Reply