Set Focus in DCBrowseCol

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Set Focus in DCBrowseCol

#1 Post by GeneB »

I am trying to set the focus in a browse to a specific cell.
In the example below, the data in a cell is tested and if the test fails
the cell is cleared and I want the focus to remain in the cell
instead of moving to the next one.
Thanks.

Code: Select all

   DCBROWSECOL ELEMENT 1 HEADER 'Item' WIDTH 15  ;
               PARENT oInput         ;
               PROTECT {|| .F. }     ;
               EDITOR 'ItemEditor'

      @ nil,nil DCGET xNil PICTURE REPL("!",20)     ;
        GETID 'ItemEditor'                          ;
        VALID {|oGet,cItem,o|                  ;
                 cItem := oGet:Get:VarGet()   ;
               , cItem := IF(OkItem(cItem), cItem, SPACE(20) ) ;
               , oGet:Get:VarPut(cItem)        ;
               , oGet:Get:UpdateBuffer()       ;
               , oInput:refreshCurrent()       ;
               , IF(EMPTY(cItem), ???? set focus back to this cell ????, nil ) ;
               , .T. } 

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

Re: Set Focus in DCBrowseCol

#2 Post by rdonnay »

Your VALID statement should return a .FALSE.. You have it returning a NIL.
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1206
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Set Focus in DCBrowseCol

#3 Post by Tom »

IMHO, it returns always .T.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

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

Re: Set Focus in DCBrowseCol

#4 Post by rdonnay »

IMHO, it returns always .T.
Tom - You are always right. :clap:
The eXpress train is coming - and it has more cars.

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Set Focus in DCBrowseCol

#5 Post by GeneB »

Thanks. This of course keeps the cursor in the cell, but the cell then turns blue and the cursor is at the same position within the cell not left aligned.
I'm not well versed in Xbase (went from Clipper straight to Express, that was the allure), so I was wondering what the Xbase code would be within the Valid block so that a touch typist can resume typing in the cell, cell not blue, cursor aligned left, without reaching for a mouse.
Thank you.

skiman
Posts: 1196
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Set Focus in DCBrowseCol

#6 Post by skiman »

Hi,

Change this

Code: Select all

... , IF(EMPTY(cItem), ???? set focus back to this cell ????, nil ) ;
    , .T. } 
to

Code: Select all

...  , IF(EMPTY(cItem), .f., .t. ) ;
     } 
Best regards,

Chris.
www.aboservice.be

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Set Focus in DCBrowseCol

#7 Post by GeneB »

thanks. I still would like to know the way to give 'uncolored' focus to the original cell and reset the cursor all the way to the left.

reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: Set Focus in DCBrowseCol

#8 Post by reganc »

Could you not use oGet:home() in your valid statement to move the cursor to the leftmost position?
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

skiman
Posts: 1196
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Set Focus in DCBrowseCol

#9 Post by skiman »

Hi,

I expected that when your 'cItem' is empty, the valid returns .F. and the cursor stays in the cell. Isn't that the case? It should!
Best regards,

Chris.
www.aboservice.be

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Set Focus in DCBrowseCol

#10 Post by GeneB »

Thank you both for your help.
Adding oGet:home() was the solution.

I now use the following:

Code: Select all

        VALID {|oGet,cItem,o|                  ;
                 cItem := oGet:Get:VarGet()    ;
               , cItem := IF(OkItem(cItem), cItem, SPACE(20) ) ;
               , oGet:Get:VarPut(cItem)        ;
               , oGet:Get:UpdateBuffer()       ;
               , oGet:home()                   ;
               , oInput:refreshCurrent()       ;
               , IF(EMPTY(cItem), .F., .T.) }
Without "home()" the cursor remains at the last position used in the cell instead of the first position.

This routine is useful when user input has to be located and verified as already in a dbf file.
When the entry isn't appropriate, clearing the cell allows the user to type it again without reaching for a mouse. The cell turns blue for the second try, which I assume is only the default color, but the cursor is in the left position and visible so I can live with that. It actually highlights the cell for another try at input so it might be better.

Thanks to everyone for their help.

Post Reply