Page 1 of 1

Return-value with Keyboard-Col-change in xBrowse

PostPosted: Sun Jul 07, 2013 11:26 am
by ukoenig
Hello,
it seems, oBrw2:bChange only works VERTICAL.
Changing the Col-pos with the KEYBOARD, nothing happens.

oBrw2:bChange := { | nRow, nCol | ( nRPos := oBrw2:KeyNo(), ;
nCPos := oBrw2:SelectedCol():nCreationOrder, ;
SEL_VKEYS(nRPos,nCPos, oGet1, oAsc) ) }


// ------------

FUNCTION SEL_VKEYS(nRPos,nCPos, oGet1, oAsc)

MsgAlert( nCPos, "Col-position" ) // doesn't work on HORIZONTAL-move

IF nCPos = 1 .or. nCpos = 2
oGet1:cText( (2)->KEY1 )
oAsc:SetText( (2)->VALUE1 )
ENDIF
IF nCPos = 3 .or. nCpos = 4
oGet1:cText( (2)->KEY2 )
oAsc:SetText( (2)->VALUE2 )
ENDIF
IF nCPos = 5 .or. nCpos = 6
oGet1:cText( (2)->KEY3 )
oAsc:SetText( (2)->VALUE3 )
ENDIF

RETURN NIL


Moving inside the table with the keybord I want to display the values on top ( get and say )
With CELL-MOUSECLICK no problem.

VERTICAL OK !!!

Image

Best Regards
Uwe :?:

Re: No return-value with Keyboard-Col-change in xBrowse ?

PostPosted: Sun Jul 07, 2013 12:54 pm
by Antonio Linares
Uwe,

bChange is related to the change of the selected record, thats why it is implemented vertical.

Maybe we should implement a bColChange to be evaluated on a column selection horizontal.

Re: No return-value with Keyboard-Col-change in xBrowse ?

PostPosted: Sun Jul 07, 2013 1:03 pm
by ukoenig
Antonio,

thank You very much for the info.
I noticed a response of bchanged with adding this line, but there is a error.

oBrw2:lColChangeNotify := .T.

from class xbrowse :
DATA lColChangeNotify AS LOGICAL INIT .f.
// if true bChange is evaluated when col is changed


Best Regards
Uwe :?:

Re: No return-value with Keyboard-Col-change in xBrowse ?

PostPosted: Sun Jul 07, 2013 1:09 pm
by Antonio Linares
Uwe,

You did it right, iI did not checked it before answering you, thanks :-)

What error do you get ?

Re: No return-value with Keyboard-Col-change in xBrowse ?

PostPosted: Sun Jul 07, 2013 1:53 pm
by nageswaragunupudi
i confirm bChange is working when column is changed even with keyboard.

Please try this small sample:
Code: Select all  Expand view
func testcolchange()

   local nRPos := 1, nCPos := 1
   local oDlg, oBrw

   USE CUSTOMER NEW ALIAS CUST SHARED

   DEFINE DIALOG oDlg SIZE 1000,400 PIXEL
   @ 40,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" AUTOCOLS ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :lColChangeNotify := .t.
      :bChange    := { || nRPos := oBrw:KeyNo(), nCPos := oBrw:SelectedCol():nCreationOrder, ;
                          oDlg:Update() }
      :CreateFromCode()
   END

   @ 10,10 SAY nRPos PICT "9999" SIZE 40,10 PIXEL OF oDlg UPDATE
   @ 10,60 SAY nCPos PICT "999" SIZE 40,10 PIXEL OF oDlg UPDATE COLOR CLR_HRED, CLR_WHITE

   ACTIVATE DIALOG oDlg CENTERED

   CLOSE CUST

return nil
 

This confirms that bchange is working correctly.
You may again recheck your code

Re: No return-value with Keyboard-Col-change in xBrowse ?

PostPosted: Sun Jul 07, 2013 2:04 pm
by ukoenig
Antonio,
It works fine now without error.

Mr. Rao,
I will check the xBrowse-section for maybe possible changes.
I got it working as well with the original code.
Incremental search in xbrowse adding the GET, is added as well.

The complete xbrowse-section :

Code: Select all  Expand view

 FUNCTION PAGE2( oFld )
LOCAL oGet1, cGet1 := "??????????"
LOCAL cKey1 := "?  ", oSay[3], oAsc

@ 5, 25 SAY oSay[1] PROMPT "V-KEY-Table" ;
OF oFld:aDialogs[ 2 ] SIZE 120, 25 FONT oFont3 PIXEL UPDATE
oSay[1]:lTransparent := .T.
oSay[1]:SetColor( nFTColor, ) // 8454143,  )

DBSELECTAREA(2)
DBGOTOP()

@ 30, 25 XBROWSE oBrw2 SIZE 265, 178 PIXEL OF oFld:aDialogs[ 2 ]  

oBrw2:nMarqueeStyle := MARQSTYLE_SOLIDCELL
oBrw2:nColDividerStyle   := LINESTYLE_BLACK
oBrw2:nRowDividerStyle := LINESTYLE_BLACK
oBrw2:bClrSelFocus = { || { 0, 16512957 } }
oBrw2:bClrSel = { || { 16777215, 255 } }
oBrw2:nRecSelColor = 15512898
oBrw2:lHScroll := .F.
oBrw2:lVScroll := .T.
oBrw2:lFooter := .F.
oBrw2:nRowHeight := 25
oBrw2:lColChangeNotify := .T.

// 1
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->KEY1 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->KEY1 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
// 2
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->VALUE1 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->VALUE1 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
// 3
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->KEY2 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->KEY2 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
// 4
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->VALUE2 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->VALUE2 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
// 5
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->KEY3 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->KEY3 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
// 6
oCol := oBrw2:AddCol()
oCol:bStrData  := { || (2)->VALUE3 }
oCol:bOnPostEdit = { | oCol, xVal, nKey | IIF ( nKey == VK_RETURN .and. NET_RLOCK( 5, 5 ), ;
                                       ( (2)->VALUE3 := xVal, ;
                                         NET_ULOCK(), oBrw2:Refresh() ), NIL) }
i := 1
FOR i := 1 TO LEN( oBrw2:aCols )
    WITH OBJECT oBrw2:aCols[i]
        oBrw2:aCols[i]:oHeaderFont := oFont2
        oBrw2:aCols[i]:bClrHeader := { || { 128,0 } }
                oBrw2:aCols[i]:oDataFont := oFont2
        oBrw2:aCols[i]:nEditType = EDIT_GET
        IF I = 1 .or. I = 3 .or. I = 5
            oBrw2:aCols[i]:nWidth  := 105
            oBrw2:aCols[i]:cEditPicture := '!!!!!!!!!!'
            oBrw2:aCols[i]:cHeader  := "VK_"
//          oBrw2:aCols[i]:SetAlign( AL_CENTER )
            oBrw2:aCols[i]:bClrstd := {|| { nBTColor1, nBColor1 } }
        ELSE
            oBrw2:aCols[i]:nWidth  := 50
            oBrw2:aCols[i]:cEditPicture := 'XXX'
            oBrw2:aCols[i]:cHeader  := "ASC"
            oBrw2:aCols[i]:bClrstd := {|| { nBTColor2, nBColor2 } }
        ENDIF      
   
    END
NEXT

oBrw2:CreateFromCode()

oBrw2:bLClicked := { | nRow, nCol | (   nRPos := oBrw2:KeyNo(), ;
                                nCPos := oBrw2:SelectedCol():nCreationOrder, ;
                                SEL_VKEYS(nRPos,nCPos, oGet1, oAsc) ) }

oBrw2:bChange := { | nRow, nCol | (  nRPos := oBrw2:KeyNo(), ;
                                  nCPos := oBrw2:SelectedCol():nCreationOrder, ;
                                  SEL_VKEYS(nRPos,nCPos, oGet1, oAsc) ) }

@ 5, 125 SAY oSay[2] PROMPT "Key :" ;
OF oFld:aDialogs[ 2 ] SIZE 40, 25 FONT oFont3 PIXEL UPDATE
oSay[2]:lTransparent := .T.
oSay[2]:SetColor( nFTColor,  )

@ 4, 170 GET oGet1 VAR cGet1 PICTURE "!!!!!!!!!!" ;
SIZE 105, 20 OF oFld:aDialogs[ 2 ] PIXEL FONT oFont3 UPDATE

oGet1:bChange = { |n,f,oGet| cKey1 := SHOW_VKEYS( TRIM( oGet1:oGet:Buffer ) ), ;
                         oBrw2:nRowSel := (2)->(ORDKEYNO()), ;
                         oBrw2:Refresh(), oAsc:Refresh() }

oGet1:bGotFocus := {|| cGet1 := SPACE(10), aTable2 := {}, oGet1:Refresh(), ;
                    cKey1 := "?  ", oAsc:Refresh() }

@ 5, 280 SAY oSay[3] PROMPT "->" ;
OF oFld:aDialogs[ 2 ] SIZE 30, 25 FONT oFont3 PIXEL UPDATE
oSay[3]:lTransparent := .T.
oSay[3]:SetColor( nFTColor,  )

@ 5, 300 SAY oAsc PROMPT cKey1 ;
OF oFld:aDialogs[ 2 ] SIZE 60, 25 FONT oFont3 PIXEL UPDATE
oAsc:lTransparent := .T.
oAsc:SetColor( nDTColor,  )

RETURN NIL

// ------------------

FUNCTION SHOW_VKEYS(cKey)
LOCAL cKeySearch := "?  "
LOCAL nKey := LEN(cKey)

DBSELECTAREA(2)
DBGOTOP()

DO WHILE !EOF()
    IF cKey = SUBSTR((2)->KEY1, 1, nKey)  
        cKeySearch := (2)->VALUE1
        EXIT
    ENDIF
    IF cKey = SUBSTR((2)->KEY2, 1, nKey)  
        cKeySearch := (2)->VALUE2  
        EXIT
    ENDIF
    IF cKey = SUBSTR((2)->KEY3, 1, nKey)  
        cKeySearch := (2)->VALUE3
        EXIT
    ENDIF

    DBSKIP(+1)
ENDDO

RETURN ( cKeySearch )

// ------------------

FUNCTION SEL_VKEYS(nRPos,nCPos, oGet1, oAsc)

// MsgAlert( nCPos, "Col-position" )

IF nCPos = 1 .or. nCpos = 2
    oGet1:cText( (2)->KEY1 )
    oAsc:SetText( (2)->VALUE1 )
ENDIF
IF nCPos = 3 .or. nCpos = 4
    oGet1:cText( (2)->KEY2 )
    oAsc:SetText( (2)->VALUE2 )
ENDIF
IF nCPos = 5 .or. nCpos = 6
    oGet1:cText( (2)->KEY3 )
    oAsc:SetText( (2)->VALUE3 )
ENDIF

RETURN NIL
 


The DBF-structure :
( with the new release I'm working on, it is possible to create Your own ASC- VKEY-table ),

Image

Best Regards
Uwe :lol:

Re: Return-value with Keyboard-Col-change in xBrowse

PostPosted: Tue Jul 09, 2013 9:37 am
by ukoenig
I got 3 possible options now :

1. a cellclick shows the result in the GET
2. xBrowse cellchange row or col, shows the cellvalue in the GET
3. defined in the GET a incremental search in xBrowse with focused cell.


All 3 actions are working now.
is it possible to change the cellcolor of the result ?
For the moment only the cellborder changes.

oBrw1:bClrSelFocus or oBrw1:bClrSel doesn' show a result.

The result now .

Image

The result wanted :

Image

Shows cellresult in GET on cellclick :

oBrw1:bLClicked := { | nRow, nCol | ( nRPos := oBrw1:KeyNo(), ;
nCPos := oBrw1:SelectedCol():nCreationOrder, ;
SEL_ASC(nRPos,nCPos, oGet1, oAsc) ) }


Shows cellresult in GET on cellchange :
8 oBrw1:lColChangeNotify := .T. 9

oBrw1:bChange := { | nRow, nCol | ( nRPos := oBrw1:KeyNo(), ;
nCPos := oBrw1:SelectedCol():nCreationOrder, ;
SEL_ASC(nRPos,nCPos, oGet1, oAsc) ) }


Incremental seek in xBrowse from GET.

oGet1:bChange = { |n,f,oGet| cKey1 := SHOW_ASC( cGet1 ), ;
oBrw1:nRowSel := (1)->(ORDKEYNO()), ;
oBrw1:nColSel := nCPos, ;
oBrw1:Refresh(), oAsc:Refresh() }


Best regards
Uwe :?: