Forums › Forums › SIMPOL Programming › dynamic menus in applicationframework, ect
- This topic has 3 replies, 2 voices, and was last updated 12 years, 1 month ago by JD Kromkowski.
- AuthorPosts
- March 29, 2012 at 12:44 pm #95JD KromkowskiParticipant
while using the application framework, I’d like to be able to change menu items. E.g., if I have a new form loaded I may want a menu that is substantially similiar but slightly different than the main menu. I can add new menuitems, but I can’t see how to delete/remove an item. I see, I think, how I could remove a whole menubar and replace it with an entirely new menubar but that doesn’t seem the correct approach, when I just want to remove one or two items. I am not seeing/finding the correct method to handle this. JDK
March 29, 2012 at 7:08 pm #1576MichaelKeymasterOn 29/03/2012 13:44, JDK wrote:
> while using the application framework, I'd like to be able to change menu items.
>
> E.g., if I have a new form loaded I may want a menu that is substantially similiar but slightly different than the main menu.
>
> I can add new menuitems, but I can't see how to delete/remove an item.
>
> I see, I think, how I could remove a whole menubar and replace it with an entirely new menubar but that doesn't seem the
> correct approach, when I just want to remove one or two items.
>
> I am not seeing/finding the correct method to handle this.
>
> JDK
>Actually, there is no method of removing menu items or menus. The MUR library stuff actually clones and inserts a menu or submenu
in a specified place and then replaces the whole menu bar.Ciao, Neil
March 29, 2012 at 8:06 pm #1916JD KromkowskiParticipantOK, not feeling so dumb. So the way to do this is to replace mb with a
new mb.JDK
Neil Robinson wrote:
> Actually, there is no method of removing menu items or menus. The MUR
library stuff actually clones and inserts a menu or submenu
> in a specified place and then replaces the whole menu bar.> Ciao, Neil
March 30, 2012 at 8:27 pm #1655JD KromkowskiParticipantReplacing whole mb is a bit more complicated that I anticipated. I can
only seem to be able to do it once without the whole mb dissappearing
altogether from the window. I'm sure I am doing something wrong. But
instead:I added the following to mainmenu()
datamenu.insert("","Employee View",enabled=.false,name= "EmployeeForm")
datamenu.insert("","Daily Record
Form",enabled=.true,name="DailyRecordForm")The following to initmainmenu(…)
mb!data.menu!EmployeeForm.onselect.function =@ ChangeForms
mb!data.menu!EmployeeForm.onselect.reference =@ app
mb!data.menu!DailyRecordForm.onselect.function =@ ChangeForms
mb!data.menu!DailyRecordForm.onselect.reference =@ app
And then created this function:
function ChangeForms(wxmenuitem me, type (application) app)
appwindow appw
appw =@ getappwindowfromwindow(getmenuitemwindow(me))
if sSecondForm == appw.form.filename
appw.mb!data.menu!EmployeeForm.setenabled(.false)
appw.mb!data.menu!DailyRecordForm.setenabled(.true)
appw.openformdirect(sFirstForm,sAPPMSGTITLE)
else
appw.mb!data.menu!EmployeeForm.setenabled(.true)
appw.mb!data.menu!DailyRecordForm.setenabled(.false)
appw.openformdirect(sSecondForm,sAPPMSGTITLE)
end if
end functionI still don't actually understand why it is "data.menu!" instead of
"datamenu!", but I know what works. - AuthorPosts
- You must be logged in to reply to this topic.