I am using an array in Xbrowse to enable/disable checkbox.
Screen Snapshot
I want to change theCheckOn, CheckOff by the user just clicking on that particular column or just by hitting the enterkey on that particular column
(Toggle switch)
Right now I am able to acheive the same but with a minor aesthetic problem.
When the user double click or hit enter key, a cursor will appear and the user has to hit enter key once again for the bitmap to change.
Is there any way to avoid this cursor from appearing in the screen. I think the trick is somewhere with bPostEdit or bEditValue, but I could not find out as I am not an expert in xBrowse
Here is the code which I have used.
- Code: Select all Expand view
@ 0,100 XBROWSE oBrwMenu ;
COLUMNS 2, 3 ;
HEADERS "Menu", "Status" ;
OF oDlg ;
ARRAY aMenu // should not use AUTOCOLS now
oBrwMenu:nMarqueeStyle:=MARQSTYLE_HIGHLROWRC
oBrwMenu:lHScroll:=.F. // Horizontal Scroll Bar not required
oBrwMenu:lFooter:=.T. // Display Footer
// Sub Menu in different colour and Menu's in different Coclour
oBrwMenu:bClrStd := { || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],aClrCol[1],aClrCol[2]) }
oBrwMenu:lUpdate := .t.
oBrwMenu:nColSel := 2
oBrwMenu:aCols[1]:nWidth:=350
// Easiest way to dispplay a BMP based on the Logical Value
*oBrwMenu:aCols[2]:SetCheck( { "CheckOn", "CheckOff" } )
// Alternative way to display BMP, if multiple conditions and more than 2 bitmaps are there
oBrwMenu:aCols[2]:AddResource("CheckOn")
oBrwMenu:aCols[2]:AddResource("CheckOff")
// Checkbox should be displayed only if the menu type is not a Submenu
oBrwMenu:aCols[2]:bBmpData :={ || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],0,iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][3],1,2)) }
oBrwMenu:aCols[2]:nWidth:=50
oBrwMenu:aCols[2]:bStrData:={ || NIL }
oBrwMenu:aCols[2]:nDataStrAlign := AL_CENTER
// No edit for SubMenu
oBrwMenu:aCols[2]:bEditWhen := { || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],.F.,.T.) }
// Edit Type is set to GET, other options are List,Button Etc.
oBrwMenu:aCols[2]:nEditType := EDIT_GET
oBrwMenu:aCols[2]:bEditvalue := { || Space(0) }
oBrwMenu:aCols[2]:bOnPostEdit:= { | oCol, xValue, nLastKey | MenuAccessOnEdit( oCol, xValue, nLastKey,oMenuArray ) }
// Enable user to click on the checkbox on column 2 only
oBrwMenu:bLClicked := { | nRow, nCol | iif(oBrwMenu:nColSel == 2,MenuAccessOnEdit(oBrwMenu:aCols[2],,,oMenuArray),NIL) }
oBrwMenu:CreateFromCode()
*---------------------------------------------*
Function MenuAccessOnEdit( oCol, xValue, nLastKey,oMenuArray )
*---------------------------------------------*
Local oBrw := oCol:oBrw
// oMenuArray is a TArray Object
if oBrw:aArrayData[oBrw:nArrayAt][3] // .T.
oBrw:aArrayData[oBrw:nArrayAt][3]:=.F.
oMenuArray:Goto(oBrw:nArrayAt)
oMenuArray:Status:=.F.
oMenuArray:save()
else
oBrw:aArrayData[oBrw:nArrayAt][3]:=.T.
oMenuArray:Goto(oBrw:nArrayAt)
oMenuArray:Status:=.T.
oMenuArray:save()
Endif
oBrw:Refresh()
Return NIL
Regards
Anser