Title: startmenu with om.dom Post by: Luca B. on January 27, 2017, 03:09:34 pm Hi all,
i try to create a new start menu dynamically with the om.domnode method. this is my code: OPEN WINDOW win01 WITH 20 ROWS , 50 COLUMNS LET txt_menu = "Prog 1.0 - ", LET aui = ui.interface.getRootNode() LET sm = aui.createChild("StartMenu") - CALL ui.Interface.loadActionDefaults(name_4ad) CALL ui.Interface.loadStyles(name_4st) CALL ui.Interface.setImage("image") CALL ui.Interface.setType("container") CALL ui.Interface.SetName("menu"||id) CALL ui.Interface.setText(txt_menu) LET smg = createStartMenuGroup(sm,"Ordering") LET smc = createStartMenuCommand(smg,"Orders","fglrun orders.42r",NULL) LET smc = createStartMenuCommand(smg,"Customers","fglrun custs.42r",NULL) LET smc = createStartMenuCommand(smg,"Items","fglrun items.42r",NULL) LET smc = createStartMenuCommand(smg,"Reports","fglrun reports.42r",NULL) LET smg = createStartMenuGroup(sm,"Configuration") LET smc = createStartMenuCommand(smg,"Database","fglrun dbseconf.42r",NULL) LET smc = createStartMenuCommand(smg,"Users","fglrun userconf.42r",NULL) LET smc = createStartMenuCommand(smg,"Printers","fglrun prntconf.42r",NULL) MENU "Example" COMMAND "Quit" EXIT PROGRAM END MENU close window win01 END MAIN FUNCTION createStartMenuGroup(p,t) DEFINE p om.DomNode DEFINE t STRING DEFINE s om.DomNode LET s = p.createChild("StartMenuGroup") CALL s.setAttribute("text",t) RETURN s END FUNCTION FUNCTION createStartMenuCommand(p,t,c,i) DEFINE p om.DomNode DEFINE t,c,i STRING DEFINE s om.DomNode LET s = p.createChild("StartMenuCommand") CALL s.setAttribute("text",t) CALL s.setAttribute("exec",c) CALL s.setAttribute("image",i) RETURN s END FUNCTION the menu work fine but is generated in the window "screen" and not in my "win01". is possible generate them in a window different from the screen? in the window "screen" the command CALL ui.Interface.SetName("menu"||id) CALL ui.Interface.setText(txt_menu) doesnėt work! why? thanks Title: Re: startmenu with om.dom Post by: Sebastien F. on January 27, 2017, 04:23:05 pm Hello Luca,
StartMenu was implemented before Genero introduced TreeViews. You may want to consider to implement your program starter with TreeView, to have full control...? You can have a look at the FGLDIR/demo/demo.4gl program. Seb Title: Re: startmenu with om.dom Post by: Leo S. on January 27, 2017, 04:46:25 pm Hi Luca, the reason that you don't see the start menu in your own window is that a "normal" window does not have a "startMenuPosition" style attribute set (see $FGLDIR/lib/default.4st), only Window.main has set <StyleAttribute name="startMenuPosition" value="menu" />
The implicit opened "screen" window has the "main" style set, thats why you see it only on "screen". Now just give your window the main style OPEN WINDOW win01 WITH 20 ROWS , 50 COLUMNS ATTRIBUTE(STYLE="main") and you see it also in your window. Nevertheless you can do everything you do with win01 also with "screen" so there is no reason to open an extra window. <<CALL ui.Interface.SetName("menu"||id) <<CALL ui.Interface.setText(txt_menu) These API calls are foreseen for MDI containers, you can use either CALL fgl_setTitle(txt_menu) --easy or DEFINE w ui.Window LET w=ui.Window.getCurrent() CALL w.setText(txt_menu) --you need a window variable HTH and Regards, Leo Title: Re: startmenu with om.dom Post by: Luca B. on January 27, 2017, 06:46:48 pm Quote Hi Luca, the reason that you don't see the start menu in your own window is that a "normal" window does not have a "startMenuPosition" style attribute set (see $FGLDIR/lib/default.4st), only Window.main has set <StyleAttribute name="startMenuPosition" value="menu" /> The implicit opened "screen" window has the "main" style set, thats why you see it only on "screen". Now just give your window the main style OPEN WINDOW win01 WITH 20 ROWS , 50 COLUMNS ATTRIBUTE(STYLE="main") and you see it also in your window. Nevertheless you can do everything you do with win01 also with "screen" so there is no reason to open an extra window. <<CALL ui.Interface.SetName("menu"||id) <<CALL ui.Interface.setText(txt_menu) These API calls are foreseen for MDI containers, you can use either CALL fgl_setTitle(txt_menu) --easy or DEFINE w ui.Window LET w=ui.Window.getCurrent() CALL w.setText(txt_menu) --you need a window variable HTH and Regards, Leo Thanks Leo S. with your solution now it work. Quote Hello Luca, for SebastienStartMenu was implemented before Genero introduced TreeViews. You may want to consider to implement your program starter with TreeView, to have full control...? You can have a look at the FGLDIR/demo/demo.4gl program. Seb i saw this solution but i want to give to the final user two solution, the "StartMenu" and the "TreeView" and in my opinion the "TreeView" is not much user friendly for a Menu thanks |