Page 1 of 1

Tree xBrowse Menu (SOLVED)

Posted: Wed Feb 21, 2018 1:43 pm
by ctoas
Hello friends.

I'm setting up a menu using xbrowse tree, but I'm not getting it to execute the function by clicking on the option. Could someone give me a light?

Image

Code: Select all

     oTreMENU := MONTAMENU()

    @ 79,00 XBROWSE oBrwMENU SIZE 400,n2 PIXEL OF oWnd ;
        DATASOURCE oTreMENU CELL LINES NOBORDER
        
        oBrwMENU:nMarqueeStyle    := MARQSTYLE_HIGHLROW 
        oBrwMENU:lrecordselector  := .F.
        oBrwMENU:lHeader          := .F.    
        oBrwMENU:lFooter          := .F.
        oBrwMENU:lHScroll         := .F.
        oBrwMENU:lVScroll         := .F.
        oBrwMENU:oFont            := ARIAL14B
        oBrwMENU:nRowHeight       := 35
        oBrwMENU:nColDividerStyle := 0
        oBrwMENU:nRowDividerStyle := 0      
        oBrwMENU:bClrStd          := {||{RGB(255,255,255), RGB(88,88,88)}}
        oBrwMENU:bClrSelFocus     := {|| {nRGB(255,255,255), nRGB(000,152,218)} }
        
        oBrwMENU:SetColor(RGB(255,255,255), RGB(88,88,88))
        oBrwMENU:aCols[1]:AddResource({"TREE_MENU_MENOS","TREE_MENU_MAIS","TREE_MENU_OPCAO"})
        oBrwMENU:CreateFromCode()
 

Code: Select all

STATIC FUNCTION MONTAMENU()

    PRIVATE aMENU := { {0,"CADASTROS"         ,""       },;
                       {1,"Empresas"          ,"F1001()"},;
                       {1,"Agenda Telefônica" ,"F1004()"},;
                       {1,"Clientes"          ,"F1003()"},;
                       {1,"Operadores"        ,"F1002()"},;
                       {1,"CEP"               ,"F1005()"} }

                       
    TREE oTreMENU
        nTREECOUNT:=0 
        nLEVEL:=aMENU[1][1]   
        FOR i:=1 TO LEN(aMENU)
            IF aMENU[i][1] > nLEVEL
                TREE
                nTREECOUNT++
            ELSEIF aMENU[i][1] < nLEVEL
                nPREVLEVEL := nLEVEL
                nCURLEVEL := aMENU[i][1]
                nLEVELDIFF := nPREVLEVEL-nCURLEVEL
                FOR j:=1 TO nLEVELDIFF
                    ENDTREE
                    nTREECOUNT--
                NEXT
                
            ENDIF    
            TREEITEM aMENU[i][2] 
            nLEVEL:=aMENU[i][1]
        NEXT                    
        IF nTREECOUNT > 0
            FOR i:=nTREECOUNT TO 1 STEP -1
                ENDTREE
            NEXT
        ENDIF 
        
    ENDTREE 

return oTreMENU
 

Thank you.

Re: Tree xBrowse Menu

Posted: Wed Feb 21, 2018 3:05 pm
by Adolfo
Hi ctoas

Code: Select all

 
oBrwTree:aCols[1]:bLDClickData:= { |r,c,f,o| If( oBrwTree:oTreeItem:bAction != nil, EVAL(oBrwTree:oTreeItem:bAction),Null() ) }
oBrwTree:bKeyChar                 := { | nKey | If( nKey == 13 .and. oBrwTree:oTreeItem:bAction !=Nil,Eval(oBrwTree:oTreeItem:bAction), Null() )}
 
Hope it helps

Greetings from Chile

Re: Tree xBrowse Menu

Posted: Wed Feb 21, 2018 6:38 pm
by ctoas
Hello Adolfo, thank you for replying.

It worked, but I could not adapt to my need.

I need something simple like this:

Code: Select all

    TREE oTreMENU
        TREEITEM "CADASTROS"
        TREE
            TREEITEM "Empresa"
            TREEITEM oItem1 PROMPT "Agenda Telefônica" ACTION MSGALERT()
            TREEITEM oItem PROMPT "Clientes"
            TREEITEM oItem PROMPT "Operadores"
        ENDTREE 
    ENDTREE
 
Where would you put a different action for each item, but in this case the "ACTION" added to the item does not respond, it's as if it did not.

Re: Tree xBrowse Menu

Posted: Thu Feb 22, 2018 9:12 am
by Otto
oBrwMENU:oFont := ARIAL14B

Hello Christiano,
can you please explain the logic how you handle FONTs.
ARIAL14B
Do you use DEFINE or how do you do.


Thanks in advance
Otto

Re: Tree xBrowse Menu

Posted: Thu Feb 22, 2018 9:48 am
by ctoas
Hello Otto.

That's right, I use DEFINE.

Code: Select all

DEFINE FONT ARIAL14B NAME "Arial" SIZE 0,-14 BOLD
PUBLIC ARIAL14B
 

Re: Tree xBrowse Menu

Posted: Thu Feb 22, 2018 3:26 pm
by nageswaragunupudi
1) Change 3rd column of aMenu as a codeblock.
Example:

Code: Select all

{ 1, "Empresas", { |o|F1001() } }, 
 
2) Change

Code: Select all

TREEITEM aMENU[i][2] 
 
as

Code: Select all

TREEITEM oItem PROMPT aMENU[i][2]
oItem:bAction := aMenu[i][3]
 
3) Assign this codeblock (as Mr Adolofo suggested)

Code: Select all

oBrw:aCols[ 1 ]:bLDClickData := { |r,c,f,o| If( o:oBrw:oTreeItem:oTree == nil,,;
                                  ( o:oBrw:oTreeItem:Toggle(), o:oBrw:Refresh() ) ), ;
                                  XEval( o:oBrw:oTreeItem:bAction, o:oBrw:oTreeItem ) } )
 
Note: From FWH1802, it will be necessary to add this codeblcock. We are incorporating this into xbrowse

Re: Tree xBrowse Menu

Posted: Fri Feb 23, 2018 7:25 pm
by ctoas
Hello friends...

It worked perfectly, thank you.

Re: Tree xBrowse Menu

Posted: Sat Mar 10, 2018 8:05 pm
by cnavarro

Re: Tree xBrowse Menu

Posted: Thu May 21, 2020 2:26 am
by ctoas
Hello friends

I think I am a little rusty and I need help in this old case and I need two more situations that I couldn't put it:
1) Add a BMP in resource on each line;
2) Activate the function in the array with an [Enter].

I appreciate any help.

PS .: C. Navarro, I looked at your linked post and found nothing.

Re: Tree xBrowse Menu

Posted: Thu May 21, 2020 3:42 am
by nageswaragunupudi
1) Add a BMP in resource on each line;
Same way you put bitmaps in other xbrowses.
2) Activate the function in the array with an [Enter].

Code: Select all

oBrw:bKeyChar := {|nKey| If( nKey == 13, ( XEval( oBrw:oTreeItem:bAction ), 0), nil ) }
 

Re: Tree xBrowse Menu

Posted: Sun May 24, 2020 1:20 am
by ctoas
Thanks for answering Rao.

It didn't work, maybe I didn't know how to express myself.

Regarding the bitmap on each line, it would be like an icon on each line based on the assembly array.

{0 , "IMG_AGENDA", "AGENDA", {| o | AGENDA ()}
{Level, image , title , function }


I think of something like this:

Code: Select all

oItem:AddImage:= aMenu[i][2]
[/b]

But I didn't find anything in the class.

With respect to running the function with Enter, the code below works, but without it I can expand or retract the menu options with Enter, which does not work when added.

Code: Select all

oBrw:bKeyChar: = {| nKey | If (nKey == 13, (XEval (oBrw:oTreeItem:bAction), 0), nil)}

Re: Tree xBrowse Menu

Posted: Tue May 26, 2020 12:20 am
by ctoas
Hello friends...

Problems solved, although the image issue didn't look the way I wanted, it was fine.

Thank you all.