Cameo Plugin to Implement On-Click Listener

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Cameo Plugin to Implement On-Click Listener

Postby amd0023@uah.edu » Mon May 13, 2019 9:42 am

Dear NoMagic Forum Member,

I am wanting to implement an on-click listener such that when a project element is clicked, a macro will run.

I know how to implement a ProjectEventListener and a PropertyChangeListener, but I am not sure of how to implement an OnClickListener.
I have researched the documentation and found nothing.

Can you please give me some advice? Any advice would be appreciated.

Thank you!

From,
Austin M. Deavers
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am

Re: Cameo Plugin to Implement On-Click Listener

Postby boris_h » Tue May 14, 2019 4:09 am

Hi, where do you want to respond on clocks? In the containment tree?

Then something like this might work:
Code: Select all
containmentTree.getTree().addTreeSelectionListener(new TreeSelectionListener() {

@Override
public void valueChanged(TreeSelectionEvent e) {
   DefaultMutableTreeNode selectedNode =
       (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
   ...         
  }
});

Basically the getTree()-Method returns the underlying JTree where you can attach various listeners.
boris_h
Forum Beginner
Forum Beginner
 
Posts: 76
Posts Rating:1
Joined: Tue May 17, 2016 8:26 am

Re: Cameo Plugin to Implement On-Click Listener

Postby amd0023@uah.edu » Tue May 14, 2019 9:16 am

I figured out the solution.

Thank you for your help!

From,
Austin M. Deavers
amd0023@uah.edu
Forum Newbie
Forum Newbie
 
Posts: 12
Posts Rating:0
Joined: Mon Mar 25, 2019 8:59 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests