Skip to main content
1-Visitor
July 9, 2015
Question

issue with customized new popup menu

  • July 9, 2015
  • 1 reply
  • 3494 views

HI Team,

              I have created one new popup menu by referring Helping Center, I called this in one of the function where that I want to be invoked,I loaded one xml document in the Arbortext Editor to check, for example

                    <simple>

                               <para>hellow john ho are u</para>

                    </simple>

when I loaded and click on some "X" menu that checks and colors all misspell words in the document, when I right click on colored text(hellow) my new custom popup menu display with some suggestions this is working as expected,

                   And what the exact problem I am facing here is, the same custom popup is displaying when I click on non colored misspell words too(ho and u), And also custom popup menu is displaying where ever I clicked(mouse right click) on the document.

Please find the attachment of custom popup function, As per the reference Help center I used m3 instead of m2 , if i use m2 changes are not affecting.

Request to provide some help on this.

Thanks,

Prashant

    1 reply

    18-Opal
    July 14, 2015

    Hi Prashant--

    Using the "map" command for m3 will just map that mouse button to do the command you specify--it's not dependent on any particular location of the mouse or condition of the document or anything like that. It's a very simple "when the user clicks that mouse button, always do X".

    If you want to make it do something different depending on whether the caret is in one of your misspelled words or not, you would need to add some tests in your function to check for that and invoke the correct menu. So it might look something like this:

    function custPopup() {

       # assume your misspelled words are wrapped in _font PIs

       if (oid_name(oid_caret())=="_font") {

          menu_popup("CustPopMennu");

       }

       else {

          menu_popup("EditPopup");

       }

    }

    map m3 custPopup();

    If you need to modify the items in your custom popup based on which specific word is highlighted, you'll need to add that in there as well. In that case, in the first branch of custPopup above, instead of calling menu_popup() directly, call another function you write that a) puts the right items in the custom popup menu based on the current word, and b) displays the menu with menu_popup().

    --Clay

    PS. For this question, and the other questions you've been posting, please take a minute to mark useful answers as either Correct (solved your problem) or Helpful (maybe didn't completely solve it, but put you on the path to a solution or workaround).

    prao1-VisitorAuthor
    1-Visitor
    July 15, 2015

    HI Clay,

                Thanks for giving example, I have tried with the given example but my changes are not effecting when I click on misspelled word.One thing I am getting confused how the mouse click event functionality work because there is no event operation written, All the functions written will be loaded at first when my menu is clicked.

                   Can I have any simple suggestion or example to follow this kind of scenarios.

    Sorry for not updating all my questions and the answers given, I will do that without any delay.

    Thanks,

    Prashant

    18-Opal
    July 16, 2015

    Hi Prashant--

    You will need to make the mouse click invoke a function that builds the menu on the fly. Here is a brief example that reflects the name of the element containing the caret when you right-click. In your case, instead of just getting the oid_name(), you'll want to call your custom Java code to get the list of alternatives for the selected word and add those to the menu. Hopefully you can generalize from this example to what you need.

    function popupCustom() {

      # get rid of the old version of the custom popup menu

      menu_delete :CustomPopup;

      # create a new one

      menu_add -menu : CustomPopup;

      local elem = oid_name(oid_caret());

      # add a menu item based on the location of the caret--can be different each time the user clicks

      menu_add :CustomPopup. "Fix $elem" -cmd { response("Fixed"); };

      # add some static items as well just for illustration

      menu_add :CustomPopup. "Other item";

      menu_add :CustomPopup. "Another item";

      # now that the menu is built, display it

      menu_popup("CustomPopup");

    }

    map m3 {popupCustom()};