Tree xBrowse Menu (SOLVED)

Post Reply
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Tree xBrowse Menu (SOLVED)

Post 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.
Last edited by ctoas on Tue May 26, 2020 12:21 am, edited 1 time in total.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
Adolfo
Posts: 815
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile
Contact:

Re: Tree xBrowse Menu

Post 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
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post 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.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Tree xBrowse Menu

Post 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post by ctoas »

Hello Otto.

That's right, I use DEFINE.

Code: Select all

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Tree xBrowse Menu

Post 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post by ctoas »

Hello friends...

It worked perfectly, thank you.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Tree xBrowse Menu

Post by cnavarro »

C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post 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.
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Tree xBrowse Menu

Post 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 ) }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post 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)}
Christiano Augusto Silveira
christiano.silveira@gmail.com

MaxxTech Soluções em TI
http://www.maxxtech.com.br
User avatar
ctoas
Posts: 103
Joined: Wed Oct 26, 2005 2:38 pm
Location: São Paulo - Brasil
Contact:

Re: Tree xBrowse Menu

Post by ctoas »

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
Post Reply