Announcement

Collapse
No announcement yet.

Menu bar issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Menu bar issue

    ive take this code from somone else in this forum ive read the loops advice and ACTUALLY WORK. the issue here its if you try to set text to an menu you cant. let me explain:

    e_ID 1 FILE
    e_ID 3-copy
    e_ID 2-paste
    e_ID 4-exit

    if you use MenuEX.SetText(3, "copytest") works perfectly.

    but if you try MenuEX.SetText(1, "FILECHANGE")
    not work, could somone assistme here?

    thanks in advance.

    BTW this is the fixed version for 8+ versions of the v7.5 code. (i dont take any credit, just ive fixed )

    Code:
    MenuEX={}
    
    local function AdjustSubMenuProperties(tSubMenu, tItemProperties)
        for nIndex, tItem in pairs (tSubMenu) do
            if tItem.ID == tItemProperties.ID then            
                for sKey, vValue in pairs (tItem) do
                    if tItemProperties[sKey] == nil then
                        tItemProperties[sKey] = vValue;
                    end
                end
                tSubMenu[nIndex] = tItemProperties;
                break;
            elseif type(tItem.SubMenu) == 'table' and tItem.ID == -1 then
                tSubMenu[nIndex].SubMenu = AdjustSubMenuProperties(tSubMenu[nIndex].SubMenu, tItemProperties);
            end
        end
        return tSubMenu;
    end
    
    --
    function MenuEX.SetChecked(nID, bChecked)
        tMenu = Application.GetMenu();
        tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Checked=bChecked});
        Application.SetMenu(tMenu);
    end
    
    function MenuEX.SetEnabled(nID, bEnabled)
        tMenu = Application.GetMenu();
        tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Enabled=bEnabled});
        Application.SetMenu(tMenu);
    end
    
    function MenuEX.SetText(nID, sText)
        tMenu = Application.GetMenu();
        tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Text=sText});
        Application.SetMenu(tMenu);
    end
    
    function MenuEX.SetIconID(nID, nIconID)
        tMenu = Application.GetMenu();
        tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, IconID=nIconID});
        Application.SetMenu(tMenu);
    end

  • #2
    Hi and Welcome to the forum.
    I have not had a great deal to do with menus but I just done this quick example for you, see if this is what you are after
    Example Menubar.apz
    Cheers

    Comment


    • #3
      Nope, look.
      this is what i want.

      when project load load this code.
      Code:
       
       MenuEX={}  local function AdjustSubMenuProperties(tSubMenu, tItemProperties)     for nIndex, tItem in pairs (tSubMenu) do         if tItem.ID == tItemProperties.ID then                         for sKey, vValue in pairs (tItem) do                 if tItemProperties[sKey] == nil then                     tItemProperties[sKey] = vValue;                 end             end             tSubMenu[nIndex] = tItemProperties;             break;         elseif type(tItem.SubMenu) == 'table' and tItem.ID == -1 then             tSubMenu[nIndex].SubMenu = AdjustSubMenuProperties(tSubMenu[nIndex].SubMenu, tItemProperties);         end     end     return tSubMenu; end  -- function MenuEX.SetChecked(nID, bChecked)     tMenu = Application.GetMenu();     tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Checked=bChecked});     Application.SetMenu(tMenu); end  function MenuEX.SetEnabled(nID, bEnabled)     tMenu = Application.GetMenu();     tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Enabled=bEnabled});     Application.SetMenu(tMenu); end  function MenuEX.SetText(nID, sText)     tMenu = Application.GetMenu();     tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Text=sText});     Application.SetMenu(tMenu); end  function MenuEX.SetIconID(nID, nIconID)     tMenu = Application.GetMenu();     tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, IconID=nIconID});     Application.SetMenu(tMenu); end
      everything works fine here.

      Menu its like this
      e_ID 1 FILE
      ----e_ID 2-copy
      ----e_ID 3-paste
      ----e_ID 4-exit


      now once the menu has been appear and whole project loads i want when i click a button insidethe text of e_ID 1 (FILE) change to FILE TEST like this:
      e_ID 1 FILE TEST <---- THE CHANGES
      ----e_ID 2-copy
      ----e_ID 3-paste
      ----e_ID 4-exit

      Actually in ur project or my code this cant be done.

      any suggest?

      Comment


      • #4
        Ok change your menu to File Test from the on menu event
        Example Menubar2.apz
        If this is still not want you are after then post your example apz

        Comment


        • #5
          you cant change a menu item by clicking that item
          that is like ask a person to Carry himself up in the air
          he can not

          but you can do that from a button
          make a button with this code


          Code:
          tblMenu = Application.GetMenu();
          tblMenu[1].ID = 100;
          tblMenu[1].Text = "FILE TEST";
          Application.SetMenu(tblMenu);

          Comment


          • #6
            Originally posted by startup View Post
            you cant change a menu item by clicking that item
            that is like ask a person to Carry himself up in the air
            he can not

            but you can do that from a button
            make a button with this code


            Code:
            tblMenu = Application.GetMenu();
            tblMenu[1].ID = 100;
            tblMenu[1].Text = "FILE TEST";
            Application.SetMenu(tblMenu);
            actually i want to make a "multilang" menu.
            many other applications in ams can, why mine doesnt?
            And i can do the stuff that i want, only thank to the people (like you) contribute helping.
            ive mix both codes to fix various things. so im gonna share it here, to be useful with somone
            [i dont share **** cuz my project its very heavy]


            AUTOPLAY MEDIA STUDIO 9 MULTI LANG MENU BAR EXAMPLE:

            --ON STARTUP CODE
            Code:
            MenuEX={}
            
            local function AdjustSubMenuProperties(tSubMenu, tItemProperties)
                for nIndex, tItem in pairs (tSubMenu) do
                    if tItem.ID == tItemProperties.ID then            
                        for sKey, vValue in pairs (tItem) do
                            if tItemProperties[sKey] == nil then
                                tItemProperties[sKey] = vValue;
                            end
                        end
                        tSubMenu[nIndex] = tItemProperties;
                        break;
                    elseif type(tItem.SubMenu) == 'table' and tItem.ID == -1 then
                        tSubMenu[nIndex].SubMenu = AdjustSubMenuProperties(tSubMenu[nIndex].SubMenu, tItemProperties);
                    end
                end
                return tSubMenu;
            end
            
            --
            function MenuEX.SetChecked(nID, bChecked)
                tMenu = Application.GetMenu();
                tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Checked=bChecked});
                Application.SetMenu(tMenu);
            end
            
            function MenuEX.SetEnabled(nID, bEnabled)
                tMenu = Application.GetMenu();
                tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Enabled=bEnabled});
                Application.SetMenu(tMenu);
            end
            
            function MenuEX.SetText(nID, sText)
                tMenu = Application.GetMenu();
                tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Text=sText});
                Application.SetMenu(tMenu);
            end
            
            function MenuEX.SetIconID(nID, nIconID)
                tMenu = Application.GetMenu();
                tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, IconID=nIconID});
                Application.SetMenu(tMenu);
            end
            
             
             tblMenu = {};
            tblMenu[1] ={};
            tblMenu[1].Text = "Herramientas";
            tblMenu[1].ID = 4;
            tblMenu[1].IconID = 0;
            tblMenu[1].Checked = false;
            tblMenu[1].Enabled = true;
            tblMenu[1].SubMenu = {};
            tblMenu[1].SubMenu[1] = {};
            tblMenu[1].SubMenu[1].Text = "&English";
            tblMenu[1].SubMenu[1].ID = 2;
            tblMenu[1].SubMenu[1].IconID = 1;
            tblMenu[1].SubMenu[1].Checked = false;
            tblMenu[1].SubMenu[1].Enabled = true;
            tblMenu[1].SubMenu[2] = {};
            tblMenu[1].SubMenu[2].Text = "&Español";
            tblMenu[1].SubMenu[2].ID = 3;
            tblMenu[1].SubMenu[2].Checked = true;
            tblMenu[1].SubMenu[2].Enabled = true;
            tblMenu[1].SubMenu[3] = {};
            tblMenu[1].SubMenu[3].Text = "&Instrucciones";
            tblMenu[1].SubMenu[3].ID = 5;
            tblMenu[1].SubMenu[3].Checked = false;
            tblMenu[1].SubMenu[3].Enabled = true;
            
            if new_version then
                tblMenu[1].SubMenu[1].Enabled = true
                tblMenu[5].SubMenu[1].Enabled = true
            end
            
            Application.SetMenu(tblMenu);

            ---ON MENU ENGLISH SECTION

            Code:
            if e_ID == 2 then
            Page.Jump("ENG");
            elseif e_ID == 3 then
            Page.Jump("ES");
            elseif e_ID == 5 then
            resultcc = DialogEx.Show("Acerca", true, nil, nil);
            end
            ---ON PRELOAD ENGLISH SECTION

            Code:
            MenuEX.SetChecked(2, true)
            MenuEX.SetChecked(3, false)
            MenuEX.SetText(3, "Español")
            MenuEX.SetText(5, "How to")
            ---ON SHOW ENGLISH SECTION

            Code:
            tblMenu = Application.GetMenu();
            tblMenu[1].ID = 4;
            tblMenu[1].Text = "Tools";
            Application.SetMenu(tblMenu);
            ---ON SHOW SPANISH SECTION
            Code:
            tblMenu = Application.GetMenu();
            tblMenu[1].ID = 4;
            tblMenu[1].Text = "Herramientas";
            Application.SetMenu(tblMenu);
            ---ON PRELOAD SPANISH SECTION
            Code:
            MenuEX.SetChecked(3, true)
            MenuEX.SetChecked(2, false)
            MenuEX.SetText(5, "Instrucciones")

            And that was all thanks to every one, ive reached the function that i want to give to the menu!

            Comment


            • #7
              Originally posted by dremuler View Post


              ---ON MENU ENGLISH SECTION

              Code:
              if e_ID == 2 then
              Page.Jump("ENG");
              elseif e_ID == 3 then
              Page.Jump("ES");
              elseif e_ID == 5 then
              resultcc = DialogEx.Show("Acerca", true, nil, nil);
              end
              Для Page.Jump(); я сделал загрузку языка из файла:

              Во вкладке on show
              -- узнаём текущий язык
              localization = INIFile.GetValue("GameData\\game.cfg", "settings", "g_language");
              -- берём название из языкового файла
              result = INIFile.GetValue("Localization\"..localization..". cfg", "settings", "text");
              -- меняем название
              Label.SetText("text", result);

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎