FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Tree xBrowse Menu (ONE MORE)
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Tree xBrowse Menu (ONE MORE)
Posted: Wed Feb 21, 2018 01:43 PM
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?



Code (fw): Select all Collapse
     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 (fw): Select all Collapse
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.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Tree xBrowse Menu
Posted: Wed Feb 21, 2018 03:05 PM
Hi ctoas


Code (fw): Select all Collapse
 
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
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Wed Feb 21, 2018 06:38 PM
Hello Adolfo, thank you for replying.

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

I need something simple like this:

Code (fw): Select all Collapse
    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.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Tree xBrowse Menu
Posted: Thu Feb 22, 2018 09:12 AM
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
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Thu Feb 22, 2018 09:48 AM
Hello Otto.

That's right, I use DEFINE.

Code (fw): Select all Collapse
DEFINE FONT ARIAL14B NAME "Arial" SIZE 0,-14 BOLD
PUBLIC ARIAL14B
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tree xBrowse Menu
Posted: Thu Feb 22, 2018 03:26 PM
1) Change 3rd column of aMenu as a codeblock.
Example:
Code (fw): Select all Collapse
{ 1, "Empresas", { |o|F1001() } },


2) Change
Code (fw): Select all Collapse
TREEITEM aMENU[i][2]

as
Code (fw): Select all Collapse
TREEITEM oItem PROMPT aMENU[i][2]
oItem:bAction := aMenu[i][3]


3) Assign this codeblock (as Mr Adolofo suggested)
Code (fw): Select all Collapse
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
Regards



G. N. Rao.

Hyderabad, India
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Fri Feb 23, 2018 07:25 PM

Hello friends...

It worked perfectly, thank you.

Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Tree xBrowse Menu
Posted: Sat Mar 10, 2018 08:05 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Thu May 21, 2020 02:26 AM

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.

Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Tree xBrowse Menu
Posted: Thu May 21, 2020 03:42 AM
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 (fw): Select all Collapse
oBrw:bKeyChar := {|nKey| If( nKey == 13, ( XEval( oBrw:oTreeItem:bAction ), 0), nil ) }
Regards



G. N. Rao.

Hyderabad, India
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Sun May 24, 2020 01:20 AM
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 (fw): Select all Collapse
oItem:AddImage:= aMenu[i][2]


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 (fw): Select all Collapse
oBrw:bKeyChar: = {| nKey | If (nKey == 13, (XEval (oBrw:oTreeItem:bAction), 0), nil)}
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu
Posted: Tue May 26, 2020 12:20 AM

Hello friends...

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

Thank you all.

Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
Posts: 115
Joined: Wed Oct 26, 2005 02:38 PM
Re: Tree xBrowse Menu (ONE MORE)
Posted: Mon Jun 14, 2021 06:01 PM
Hello friends!!

In this menu where the images are in this line, I can replace them with common characters, like "+", "-" and ">" ???

Code (fw): Select all Collapse
oBrwMENU:aCols[1]:AddResource({"TREE_MENU_MENOS","TREE_MENU_MAIS","TREE_MENU_OPCAO"})


I've already looked, but maybe through carelessness I didn't find how to do it.

Thanks
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br

Continue the discussion