cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

issue with customized new popup menu

prao
7-Bedrock

issue with customized new popup menu

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

10 REPLIES 10

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).

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

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()};

HI Clay,

            Thanks clay this code helped me a lot, I have done event operations using java, and my new custom popup is in ACL as helped. I am trying to call ACL function that is custom popup on click event

          ex: -

    (EventTarget)doc).addEventListener("click",

      new EventListener() {

    public void handleEvent(Event event) {

    if(node.getNodeName().compareToIgnoreCase("_font") == 0){

      Acl.func("popupCustom"); // getting [A30158] The java method handleEvent has thrown an exception

    }

I am not able to trace it out where exactly the problem, but the logs are generating on Arbortext Console to trace it.

Is that I am doing any wrong on calling function in click event ?

Thanks,

Prashant

Hi Prashant--

I guess I would need to see what the exception is to know what advice to give. You could try using Acl.execute("popupCustom()") instead of Acl.func() to see if that give a better result.

If not, you could always use a try/catch block in your Java code to pop up the exception message, something like this:

(EventTarget)doc).addEventListener("click",

      new EventListener() {

    public void handleEvent(Event event) {

    if(node.getNodeName().compareToIgnoreCase("_font") == 0){

    try {

       Acl.func("popupCustom"); // getting [A30158] The java method handleEvent has thrown an exception

    }

    catch (Exception ex) {

       Application.alert("Exception in popup menu: " + ex.getMessage());

    }

    }

Hopefully that will help with troubleshooting.


--Clay

Hi Clay,

             I kept try catch block too, and also tried with Acl.execute("popupCustom") too.Please find the stack trace I got in the Arbortext console.

com.arbortext.epic.AclException: Error parsing command string:

popupCustom()

[A11354] Unrecognized function call: popupCustom()

  at com.arbortext.epic.Acl.doEval(Native Method)

  at com.arbortext.epic.Acl.access$400(Acl.java:24)

  at com.arbortext.epic.Acl$5.call(Acl.java:305)

  at com.arbortext.epic.Acl$5.call(Acl.java:302)

  at com.arbortext.epic.AOMAccessController.execute(AOMAccessController.java:150)

  at com.arbortext.epic.Acl.eval(Acl.java:310)

  at com.arbortext.epic.Acl.func(Acl.java:446)

  at HyperSTENewCust$1.handleEvent(HyperSTENewCust.java:89)

Thanks,

Prashant

Hi Prashant--

OK, based on that message, it looks like it's not finding your popupCustom function. Make sure that the ACL file that defines this function gets loaded before you try to use the feature (which you can do by putting it in $APTCUSTOM/init). Also, if you have defined a package name in the file where this function is defined, include the package modifier when you call the function. For example, if your ACL file has this near the top:

     package customMenus;

Then you will need to use Acl.func("customMenus::popupCustom").

What happens if you type "popupCustom()" in the command line in the editor window? Does it work or does it give an error?

--Clay

HI Clay,

            gr8, now no exception if I use Acl.execute("customMenus::popupCustom") no exceptions its working thanks a lot. But my popup is displaying every where i clicked on screen instead of showing on particular text. Checking that ..

Thanks,

Prashant

Hi Prashant--

Oh, wait, I think I see the problem. In your event handler anonymous function, you reference "node" but it's never defined. I suspect that's causing the problem. Try changing this line:

    if(node.getNodeName().compareToIgnoreCase("_font") == 0){


to something like this:

    if(event.target.getNodeName().compareToIgnoreCase("_font") == 0){


Hopefully that will work better.

--Clay

HI Clay,

            Reference "node" is defined in code , I gave only the piece of block where exactly the issue.Its giving some exception.

com.arbortext.epic.AclException: Error parsing command string:

popupCustom()

[A11354] Unrecognized function call: popupCustom()

  at com.arbortext.epic.Acl.doEval(Native Method)

  at com.arbortext.epic.Acl.access$400(Acl.java:24)

  at com.arbortext.epic.Acl$5.call(Acl.java:305)

  at com.arbortext.epic.Acl$5.call(Acl.java:302)

  at com.arbortext.epic.AOMAccessController.execute(AOMAccessController.java:150)

  at com.arbortext.epic.Acl.eval(Acl.java:310)

  at com.arbortext.epic.Acl.func(Acl.java:446)

  at HyperSTENewCust$1.handleEvent(HyperSTENewCust.java:89)

Thanks,

Prashant

Announcements

Top Tags