Announcement

Collapse
No announcement yet.

is favorite button/app/script possible?

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

  • is favorite button/app/script possible?

    Hello,
    I want to make a menu/submenu item for user's favorite applications. But it should be dynamic that users can choose their favorites. Is it possible with SC? Does anyone have any idea for that?

  • #2
    You would need to create a table (or add fields to an existing table) that records apps that a user marks as a favourite (I presume by an "add favorite" button you create to go on the toolbar of every eligible app).

    That button's function would be to update the table recording the apps against a particular user.

    Then in the menu app's onApplicationInit, read that table and use the SC macros below to dynamically create the menu items:

    This Macro adds dynamically an item to the menu:
    sc_appmenu_add_item ("Menu_Name", "Id_Item", "Id_Parent", "Label", "Application", "Parameters", "Icon", "Hint", "Target")

    This macro dynamically creates a menu item:
    sc_appmenu_create ("Menu_Name")

    This macro checks if there is a menu item:
    sc_appmenu_exist_item ("Menu_Name", "Id_Item")

    Comment


    • #3
      Originally posted by adz1111 View Post
      You would need to create a table (or add fields to an existing table) that records apps that a user marks as a favourite (I presume by an "add favorite" button you create to go on the toolbar of every eligible app).

      That button's function would be to update the table recording the apps against a particular user.

      Then in the menu app's onApplicationInit, read that table and use the SC macros below to dynamically create the menu items:

      This Macro adds dynamically an item to the menu:
      sc_appmenu_add_item ("Menu_Name", "Id_Item", "Id_Parent", "Label", "Application", "Parameters", "Icon", "Hint", "Target")

      This macro dynamically creates a menu item:
      sc_appmenu_create ("Menu_Name")

      This macro checks if there is a menu item:
      sc_appmenu_exist_item ("Menu_Name", "Id_Item")
      I'll check it, thanks!

      Comment


      • #4
        Originally posted by adz1111 View Post
        You would need to create a table (or add fields to an existing table) that records apps that a user marks as a favourite (I presume by an "add favorite" button you create to go on the toolbar of every eligible app).

        That button's function would be to update the table recording the apps against a particular user.

        Then in the menu app's onApplicationInit, read that table and use the SC macros below to dynamically create the menu items:

        This Macro adds dynamically an item to the menu:
        sc_appmenu_add_item ("Menu_Name", "Id_Item", "Id_Parent", "Label", "Application", "Parameters", "Icon", "Hint", "Target")

        This macro dynamically creates a menu item:
        sc_appmenu_create ("Menu_Name")

        This macro checks if there is a menu item:
        sc_appmenu_exist_item ("Menu_Name", "Id_Item")
        Hi again,
        I couldn't add a menu item to my menu. I'm trying to add with sc_appmenu_add_item ("Menu_Name", "Id_Item", "Id_Parent", "Label", "Application", "Parameters", "Icon", "Hint", "Target") in my Menu's OnApplicationInit

        Comment


        • #5
          You need to say more:

          1) What happens?
          2) Any error messages?
          3) Show the code you have written?
          4) Screen shots?

          We may or may not know the answer, and most here are happy to try and help (time and other circumstances permitting) - and some of us are better than others. But whether we are any good or not - we are not psychic :-)

          Comment


          • #6
            Originally posted by adz1111 View Post
            You need to say more:

            1) What happens?
            2) Any error messages?
            3) Show the code you have written?
            4) Screen shots?

            We may or may not know the answer, and most here are happy to try and help (time and other circumstances permitting) - and some of us are better than others. But whether we are any good or not - we are not psychic :-)
            it's just doesn't work. I already have a menu and I'm writing that code in this application / ApplicationInit. There is no error messages. and Nothing happens.

            Code:
            sc_appmenu_add_item('menu','item_1','new_menu_item _1','app_test','app_test','','','','');

            I didn't explain because of there is like nothing, it could be about my codes. I'm trying to add static menü item first.
            Thanks for your interest.

            Comment


            • #7
              Ok...

              1) That line of code is the only code in onApplicationInit?

              2) In your menu, do you already have any items defined?

              Comment


              • #8
                sekr

                Ok - not having used dynamic menus before I had a little play....

                Some key things:

                The ...add_item, ...remov_item macros etc rely on an array being created first using the sc_appmenu_create macro (it says this in the help). So, you need to run this first giving the name of your existing menu app. If your menu app is called 'menu', then within that app's onApplicationInit call this:

                Code:
                sc_appmenu_create('menu');
                It looks like this array persists somewhere, and overrides any menu items you have already defined. So if you do the _create, it ignores any pre-defined menu items (it doesn't delete them, it's just an either / or situation - either static menu, or dynamic menu - not both).

                This array will be empty when you create it - so you will have to use sc_appmenu_add_item() for all your normal "static" menu items, as well as the actual variable dynamic items. Because the array persists your onApplicationInit code should check for existance of that array so your app doesn't rebuild the whole menu every time, e.g.

                Code:
                if(sc_appmenu_exist_item('menu', 'item_1')) {       // first root item already defined? If not build the main "static" menu
                    
                    sc_appmenu_create('menu');    // create initial 'empty' array
                
                    sc_appmenu_add_item('menu','item_1','','First Root Item','','','','');
                    sc_appmenu_add_item('menu','item_2','','Second Root Item','','','','');
                    sc_appmenu_add_item('menu','item_3','item_1','First Root sub-Item','app_name1','','','');
                    .......
                
                } else {          // otherwise do your dynamic mods here
                    
                    // your logic to read your favorites table, e.g. {some_fave_field}
                    
                    foreach(.......) {    //loop through and ... add / update / remove accordingly
                        
                        if(sc_appmenu_exist_item('menu', {some_fave_field})) {
                            If (.......) {
                                sc_appmenu_update_item(...);     // update an existing item
                            } else {
                                sc_appmenu_remove_item(...);    // remove an existing item
                            }
                        } else {
                            sc_appmenu_add_item(...);        // add a new item
                        }
                
                    }
                }
                If at any point you wish to remove this persistent array (e.g. you wish to start again - or just use the pre-defined items in the menu app), call this:

                Code:
                sc_appmenu_reset('menu');
                NOTE: You can also use onLoad if you need to update menu "immediately", in which case just have the main static build in onApplicationInit, and the dynamic logic on onLoad.

                Good luck :-)

                Comment


                • #9
                  Thanks a lot

                  Comment

                  Working...
                  X