xBrowse SetCheck,Bitmap Column and bEditValue

xBrowse SetCheck,Bitmap Column and bEditValue

Postby anserkk » Tue Dec 16, 2008 12:39 pm

Hi freinds,

I am using an array in Xbrowse to enable/disable checkbox.

Screen Snapshot

Image

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
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Daniel Garcia-Gil » Tue Dec 16, 2008 7:03 pm

use "on change" clause

Code: Select all  Expand view
xbrowse oBrw.... on change SetEdit( oBrwMenu )

procedure SetEdit( obrw )

if oBrw:aArraydata[ oBrw:nArrayAt ][4]
oBrw:aCols[ 2 ]:nEditType = EDIT_NONE
else
  oBrw:aCols[ 2 ]:nEditType = EDIT_GET
endif
return


i hope you do understand me
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby anserkk » Wed Dec 17, 2008 5:34 am

Dear Daniel,

Thank you for the help, but it is not the solution which I am looking for.

I tried your code but it did not make any difference

If you look at my code posted above, you will find that I have used bEditWhen to acheive the same what you have adviced me to do with the ON CHANGE

Code: Select all  Expand view
oBrwMenu:aCols[2]:bEditWhen  := { || iif(oBrwMenu:aArrayData[oBrwMenu:nArrayAt][4],.F.,.T.) }


With the above piece of code I am able to restrict the GET on Sub Menu Items Line (Dark Blue)

Sub Menu Items Line -> Dark Blue Colour (Edit NOT Required)
Menu Items Line -> Light Blue Colur (Edit Required but without a GET appearing )

My problem is that when the user hits enter key or double click on a Menu Item Line (Light Blue) a GET is appearing, which I don't want.

I need the xbrowse to work like a Toggle only on the menu Item line (Light Blue colour) without a GET appearing.

Hope I have explained my requirement clearly.

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Daniel Garcia-Gil » Wed Dec 17, 2008 6:12 am

hello...

try it...
Code: Select all  Expand view
    oBrw:bKeyDown= {|nKey| if ( nKey  == VK_RETURN, ;
PostMessage( oBrw:hWnd, WM_KEYDOWN, 27 ), ) }
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby anserkk » Wed Dec 17, 2008 6:26 am

Hi Daniel

Thankyou

Code: Select all  Expand view
oBrw:bKeyDown= {|nKey| if ( nKey  == VK_RETURN, ;
PostMessage( oBrw:hWnd, WM_KEYDOWN, 27 ), ) }


The above code is working with the Enter Key, but Mouse double click is still activating a GET

Another problem is that If the active column is not the 2nd column then the Dialog itself is getting closed. I think it is because of the PostMessage 27.

So I changed your sample code to

Code: Select all  Expand view
oBrwMenu:bKeyDown= {|nKey| if(oBrwMenu:nColSel == 2,if ( nKey  == VK_RETURN, PostMessage( oBrwMenu:hWnd, WM_KEYDOWN, 27 ), ),) }


Any hint to solve the Mouse double click ? Mouse Single click is working fine.

Is there any way to contol the active column to be always 2
ie oBrwMenu:nColSel should be always 2

Regards

Anser
Last edited by anserkk on Wed Dec 17, 2008 8:00 am, edited 1 time in total.
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Wed Dec 17, 2008 7:58 am

Is there any way to contol the active column to be always 2
ie oBrwMenu:nColSel should be always 2


I solved active column issue by changing the the bKeyDown to make Column 2 as Selected column before the PostMessage

Code: Select all  Expand view
oBrwMenu:bKeyDown= {|nKey| oBrwMenu:nColSel:=2 ,if ( nKey  == VK_RETURN, PostMessage( oBrwMenu:hWnd, WM_KEYDOWN, 27 ), ) }


I don't know whether this is the right way or is there any other way of doing it. I beleive that there should be someway to disable a column or a way to enable only a particular column and disable other columns

Any hint to solve the Mouse double click ? Mouse Single click is working fine.

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Detlef Hoefner » Wed Dec 17, 2008 12:46 pm

Anser,

your program is a very nice approach for a tree-like browser.
I'd like to work with your code because it could be useful for me too.

May be i could find a hint.
Could you please, post a little more code and your rc file?

My first idea for your problem is to try the bWhen block of column 2.

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Daniel Garcia-Gil » Wed Dec 17, 2008 1:11 pm

puedes publicar el methodo LDblClick del xbrowse de tu version? o me lo mandas al correo danielgarciagil@gmail.com, mi messenger es danielgarciagil@cantv.net
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby demont frank » Wed Dec 17, 2008 1:25 pm

Ansserk

I am using :

Code: Select all  Expand view
definig the browse :

SetEditBlock(oBrw,{|nKey| (cAlias)->(Editprog(oBrw,nKey)) })             



*************************************************************************************************************
PROC SetEditBlock(oBrw , EditBlock , aKeys)
******************************************
LOCAL el
oBrw:bLDblClick := EditBlock
//OBrw:bPastEof() := EditBlock
IF IsArray(aKeys)
   IF ASCAN(aKeys,13) == 0
      AADD(aKeys,13)
   END
   oBrw:bkeyDown  := { | nkey | IIF( (nKey IN aKeys) , EVAL(EditBlock,nKey) ,  ) }
else
   oBrw:bkeyDown  := { | nkey |IIF(nkey==13 , EVAL(EditBlock) ,  ) }
endif
RETURN
************************************************
PROC EditProg(oBrw,nKey)
**********************
LOCAL    nr := oBrw:nArrayAt
LOCAL nCol := oBrw:nColsel
LOCAL cTit
IF nCol > 0 .AND. nCol <= LEN(oBrw:aDisplay) // oBrwB:aCols)
    //cTit := oBrwB:SelectedCol():cHeader
    nCol := oBrwB:SelectedCol():nArrayCol
END
IF nCol == 2
      // Not needed , only column 2 has to be changed with enter or dblclick
     oBrw:aRow[nCol] := !oBrw:aRow[nCol
    //oBrw:aArrayData[Nr,nCol] := i oBrw:aArrayData[Nr,nCol]
     oBrw:RefreshCurrent()
END
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby anserkk » Thu Dec 18, 2008 6:39 am

Daniel,

I am using xBrowse of FWH 8.08

Is there any other way to handle this problem without modifiying the original XBrowse Source Code

I am herewith pasting code of xbrowse Method LDblClick

Code: Select all  Expand view
METHOD LDblClick( nRow, nCol, nKeyFlags ) CLASS TXBrowse

   local oCol
   local nColPos, nRowPos

   ::CancelEdit()
   ::Seek()

   nColPos := ::MouseColPos( nCol )
   nRowPos := ::MouseRowPos( nRow )

   if nColPos == ::nColSel .and. nRowPos == ::nRowSel
      oCol := ::ColAtPos( nColPos )
      if oCol:nEditType > 0
         if ( oCol:bEditWhen == nil .or. Eval( oCol:bEditWhen, oCol ) )

            if oCol:hChecked .and. oCol:bOnPostEdit != nil
               Eval( oCol:bOnPostEdit, oCol, ! Eval( oCol:bEditValue ), 13 )
               ::DrawLine( .t. )
            else
               return oCol:Edit()
            endif

         endif
      elseif oCol:bLDClickData != nil
         return Eval( oCol:bLDClickData, nRow, nCol, nKeyFlags, oCol )
      endif
   endif

   If nColPos != 0 .and. nRowPos != 0
      return Super:LDblClick( nRow, nCol, nKeyFlags )
   Endif

return 0
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Thu Dec 18, 2008 6:46 am

Hi Detlef,

I'd like to work with your code because it could be useful for me too.
Could you please, post a little more code and your rc file?


I fetch data from MySql and create an array with space added to the left of array elements based on the data heirarchy.

My .RC contents. I use .RC only for Images

Code: Select all  Expand view
Save24x24            BITMAP  Images\Save24x24.Bmp
Cancel24x24          BITMAP  Images\Cancel24x24.Bmp


If you can provide your email ID, I can send my source code to you.

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Detlef Hoefner » Thu Dec 18, 2008 7:39 am

Hi Anser,

many thanks for your kind offer which is highly apreciated.
My email Id is ...

Best regards,
Detlef
Last edited by Detlef Hoefner on Thu Dec 18, 2008 8:20 am, edited 1 time in total.
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby anserkk » Thu Dec 18, 2008 8:17 am

Detlef,

Please check your email.

Regards

Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Detlef Hoefner » Thu Dec 18, 2008 8:25 am

anserkk wrote:Detlef,

Please check your email.

Regards

Anser

Hi Anser,

many thanks again for sending your source.
It's a great resource for me to learn about additional possibilities of xBrowse.

Best regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 14 guests