Skip to content

dynamic menus in applicationframework, ect

Forums Forums SIMPOL Programming dynamic menus in applicationframework, ect

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #95
    JD Kromkowski
    Participant

    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

    #1576
    Michael
    Keymaster

    On 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

    #1916
    JD Kromkowski
    Participant

    OK, 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

    #1655
    JD Kromkowski
    Participant

    Replacing 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 function

    I still don't actually understand why it is "data.menu!" instead of
    "datamenu!", but I know what works.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.