# How to implement right-click context menu in paraview plugin way

**URL:** https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880
**Category:** Development
**Created:** [May 18, 2019, 8:19am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880 "2019-05-18T08:19:14Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 18, 2019, 8:19am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/1 "2019-05-18T08:19:14Z")

</div>

Dear Experts,  
I want to implement my own right-click context menu and hide paraview default one in paraview plugin way.  
I read some paraview source code, I found I can create similar class like pqPipelineContextMenuBehavior, However, the difficult is i want to use paraview plugin to implement it, and must keep paraview source code untouched!

My question is: is it possible to use plugin to fulfill this? How to do?

Could you please help me out!

Thanks in advance!

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 18, 2019, 2:14pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/2 "2019-05-18T14:14:47Z")

</div>

this is not supported via plugins. Plugins are intentionally not intended to `remove` functionality.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 19, 2019, 12:05am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/3 "2019-05-19T00:05:48Z")

</div>

Hi Utkarsh,  
Thank you for your reply!  
Then if it is impossible in plugin way, what is the suggested way?  
I should create my own application?

Best Regards

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 20, 2019, 8:29am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/4 "2019-05-20T08:29:55Z")

</div>

Hi Sharon,

To _remove_ functionnality, you are suposed to create a ParaView based application.  
See Examples/Applications/ in ParaView source code.

In any case, contextual menu is always widget specific, so you won’t be able to change the behavior of the right click on the whole application.

What are you trying to achieve exactly ?

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 1:36pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/5 "2019-05-20T13:36:52Z")

</div>

Hi Mathieu,  
Thank you for your reply!

I want to have more control on context menu, like i want there are some specific menu actions when after right click.  
For example, i want show information about each leaf type of a tree, how many leaves on this tree, how long of the longest tree trunk, How many trunk bifurcation points…

By the way, i also need to read each trunk from different files but into one vtkMultiBlockDataset, how can i achieve this?

Thanks in Advance!

Best Regards,  
Sharon

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 20, 2019, 1:38pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/6 "2019-05-20T13:38:23Z")

</div>

> [@sharon](#):
>
> I want to have more control on context menu, like i want there are some specific menu actions when after right click.  
> For example, i want show information about each leaf type of a tree, how many leaves on this tree, how long of the longest tree trunk, How many trunk bifurcation points…

In which widget ? The pipeline browser ? You can just reimplement a PipelineBrowser and define your own contextual menu.

> [@sharon](#):
>
> By the way, i also need to read each trunk from different files but into one vtkMultiBlockDataset, how can i achieve this?

Use GroupDataSet filter ?

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 1:44pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/7 "2019-05-20T13:44:11Z")

</div>

Yes, in the pipeline browser.  
Thank you, i will try!

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 1:45pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/8 "2019-05-20T13:45:07Z")

</div>

i haven’s used GroupDataSet, this can be used in the reader?

Thank you for your prompt reply!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 20, 2019, 1:47pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/9 "2019-05-20T13:47:53Z")

</div>

It is a filter in ParaView. But I’m not sure what you are trying to achieve here.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 1:52pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/10 "2019-05-20T13:52:45Z")

</div>

I want to read data from different files but want set all the data into one single vtkMultiBlockDataSet

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 20, 2019, 1:54pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/11 "2019-05-20T13:54:49Z")

</div>

- Open ParaView
- Read all your data with multiple readers, Apply
- Select all your reader in the pipeline browser using the mouse and keeping “Ctrl” key pressed
- Filter -\> Alphabetical -\> Group DataSet
- Apply

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 2:02pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/12 "2019-05-20T14:02:56Z")

</div>

Thank you Mathieu!  
This is clear!

Is it possible for me write my own reader that can achieve the same result?

Thanks a lot!

Sharon

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 20, 2019, 2:05pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/13 "2019-05-20T14:05:44Z")

</div>

There are multiple ways to achieve that :

- Custom Filters (tools -\> Create Custom Filters (GUI based))
- Programmable Source ( source -\> Programmable Source (Python based))
- meta reader in a C++ plugin ( require compilation, C++ based)

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 2:09pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/14 "2019-05-20T14:09:04Z")

</div>

Hi Mathieu,  
I prefer c++ plugin way, however, i found each reader can only read one file, the architecture already define inside the paraview, it is impossible for me to let one reader to read multiple files…

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [May 20, 2019, 2:11pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/15 "2019-05-20T14:11:08Z")

</div>

This is a secondary answer to the earlier question about reading all the data into a single `vtkMultiBlockDataSet`. ParaView allows several types of files to be read in as a time series if their files have a conventional numbering (e.g. file0.vtk, file1.vtk, file2.vtk, etc.). If your file type supports this, you can read the data as a time series and then run the `Group Time Steps` filter to combine the data from all time steps into a single `vtkMultiBlockDataSet`. That tends to be a lot easier than trying to open all the files separately.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 20, 2019, 2:17pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/16 "2019-05-20T14:17:39Z")

</div>

Thank you Kenneth for your reply!

Is it possible or how to write my own reader to achieve this?

Thanks in advance!  
Best Regards,  
Sharon

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [May 20, 2019, 2:39pm UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/17 "2019-05-20T14:39:15Z")

</div>

@mwestphal pretty much covered the options. The only addition I would add would be to build a python macro, which is usually my go-to solution. The only problem is that AFAIK there is no way to open the file dialog from a macro.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [January 30, 2021, 2:21am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/18 "2021-01-30T02:21:03Z")

</div>

@sharon Context-menus via plugins are coming soon to ParaView. [This post](https://discourse.paraview.org/t/adding-a-context-menu-to-paraview/6344) describes the mechanism being added to allow user-provided menus. It will allow plugins to omit ParaView’s menu if needed, although this may not be advisable in all cases.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [January 30, 2021, 3:06am UTC](https://discourse.paraview.org/t/how-to-implement-right-click-context-menu-in-paraview-plugin-way/1880/19 "2021-01-30T03:06:11Z")

</div>

Hi David,  
This is great!  
Although i already wrote my own application, this still interested me, i will have a try later.  
Thanks and best regards,  
sharon
