OnContextMenu event not triggered when right click


Recommended Posts

I am try to write code for OnContextMenu Event for a symbol, specifically, to popup a system message box. However, when I right click the symbol, the mesage does not pop up, and instead normal add components menu pops up. When I move the code to OnLButtonDblClk and OnLButtonUp, the code works fine. How to make OnContextMenu work then? Thanks.

Link to comment
Share on other sites

Because the component menu is needed for development mode, what you described really only works in runtime mode. You can, however, easily switch between runtime and development mode by going File - Switch to Runtime, or when in runtime mode, click on the icon in the top left or hit Ctrl-Space, and select Switch to Development

Link to comment
Share on other sites

Thanks for the replay. However, I tried it in runtime mode, it does not give response either. The code written in OnContextMenu is

if (System.MessageBox("Do you want to delete this sensor?","OKCancel") == "OK")
   if (System.MessageBox("Are you sure?","OKCancel") == "OK")
	  ?"Deleted this sensor."
   endif 
endif

Link to comment
Share on other sites

Hmm, works fine for me. Which version of DAQFactory are you running? I'm running the latest off our site: 5.77, build 1531. Maybe you can attach your document, or a sample showing it not working.

Also, check out my blog entry on avoiding shipping test code. I would use a similar technique here, so that your popup only appears when in runtime mode. It could get pretty annoying in development mode.

Link to comment
Share on other sites

  • 9 months later...

What was the resolution to this post? I am having the same issue and I am on DAQ version 5.79A build 1574.

For Text type components (e.g Text and descriptive text) the OnContext Event does not work properly in runtime mode or development mode. There are other bugs I have found in using Events with components:

The first problem I noticed Is that when using "text components" the OnContext event actually does work a little in development mode with the problem being that it only works if you click below the component in the right area which I found by vigorously right clicking all over & near the component.

This led me to explore click area and tolerance with respect to components and events. I put together a test

application that you can try yourself

Another problem with text components is that in runtime mode the DBLClick Even does not work

Test.ctl

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.