Using 'Protect' in a Browse

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:

Using 'Protect' in a Browse

#1 Post by GeneB »

I am trying to protect an item in a browse.
If an unprotected cell is edited and the up or down arrow moves to the protected cell it can then be edited.
When up/down leaves the protected cell, the focus goes to the bottom cell in the browse.

What am I missing, please.
Thanks, GeneB

Code: Select all

FUNCTION Test()
local nPointer, aList, oBrowse, oFrame

aList := { {11,"Unknown"} ;
          ,  {12,"Chain"}      ;
          ,  {13,"Bulb"}        ;
          ,  {14,"Glass"}       ;
          ,  {15,"Wire"}       ;
          ,  {16,"Parts"}      }

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX ;
   SIZE 100,25 ;
   OBJECT oFrame

   @ 2,2 DCBROWSE oBrowse PARENT oFrame ;
      DATA aList SIZE 31,21 ;
      FREEZELEFT {1,2} ;
      POINTER nPointer ;
      EDIT xbeBRW_ItemSelected MODE DCGUI_BROWSE_EDITDOWN

      DCBROWSECOL ELEMENT 1  HEADER "Num"  PARENT oBrowse WIDTH 4 ;
         PROTECT {|| .T.}

      DCBROWSECOL ELEMENT 2  HEADER "Name" PARENT oBrowse WIDTH 13 ;
         PROTECT {|| ListProtect(aList[nPointer,1]) }

DCREAD GUI FIT
RETURN NIL


STATIC FUNCTION ListProtect(nNum)
IF nNum = 13
   RETURN .T.
ENDIF
RETURN .F.

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

Re: Using 'Protect' in a Browse

#2 Post by GeneB »

Ok, I imagined it was pretty simple but maybe it isn't possible to protect a single cell in DC_Browse.
Let me take a different approach. How can I prevent navigation through a browse with the up/down arrows and require a mouse click to move from cell to cell? PROTECT works when a cell is entered via a mouse click.
Thanks,
GeneB

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

Re: Using 'Protect' in a Browse

#3 Post by rdonnay »

The basic, built-in cell-editor is very limited on capability. You need much more control and you can build your own cell-editing system. Look at the sample in \exp19\samples\celledit.
The eXpress train is coming - and it has more cars.

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

Re: Using 'Protect' in a Browse

#4 Post by skiman »

Hi,

Protecting a cell from editing can be done the following way:

Code: Select all

DCBROWSECOL ELEMENT 1  HEADER "Num"  PARENT oBrowse WIDTH 4 ;
         EDITOR {|| NIL }
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: Using 'Protect' in a Browse

#5 Post by GeneB »

Thanks, Chris, but your suggestion protected the entire column of cells.

I was looking for a way to protect a single cell in a column and allow editing of the other cells, and I found a way to do it: use HIDE in the editor:

Code: Select all

DCBROWSECOL ELEMENT 2 HEADER "Name" PARENT oBrowse WIDTH 13 ;
   EDITOR 'NameEditor'

@ nil,nil DCGET xNil PICTURE "!!!!!!!!!!" ;
   HIDE {|| nPointer==3} ;
   GETID 'NameEditor'

Thanks, Gene

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

Re: Using 'Protect' in a Browse

#6 Post by rdonnay »

The protect clause is a code block, so I don't see why this would not work. The code block needs to take into consideration the data in that row.

Example:

DCBROWSECOL ELEMENT 2 PROTECT {||oBrowse:arrayElement == 2}
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: Using 'Protect' in a Browse

#7 Post by GeneB »

It does work, but when using the up/down arrows in the edit mode, the protected cell is skipped as well as the next one. In other words, it skips two cells (rows). If the protected cell is the first or second in the browse, it works correctly with the up arrow (can't skip two cells).

In my opinion using HIDE gives the user a smoother transition from edited cell to protected cell and back. The protected cell is displayed in it's browse color rather than just skipped.

GeneB

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

Re: Using 'Protect' in a Browse

#8 Post by rdonnay »

Are you saying that the HIDE has solved your problem?
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: Using 'Protect' in a Browse

#9 Post by GeneB »

Yes, using HIDE in a cell editor solved the whole problem.
It works nicely.
Thanks

Post Reply