|
API 2.8.0 standalone Chart right-click context menu |
hyperscalper
|
Post subject: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 00:11
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Standalone API chart now has right-click context menu as shown on screenshot. How can I suppress and/or replace the right-click context menu which has appeared with the 2.8.0 API update? I don't want my users exposed to submit an order using that default mechanism, as it will not place correct Label fields, etc. which my application requires. HyperScalper
Attachments: |
APIChartContextMenuUnwanted.png [175 KiB]
Downloaded 738 times
|
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.
|
|
|
|
|
|
jlongo
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 01:09
|
|
User rating: 94
Joined: Mon 06 Feb, 2012, 12:22 Posts: 357 Location: Portugal, Castelo Branco
|
Hi hyperscalper:
One fast workarround suposing you don't need right click on any part of your program is capture the event and discard it until the developers implement any way to enable/disable it
Trade well
JL
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 04:47
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
...need some help, tried to override/redefine the behavior unsuccessfully.... I tried installing an alternate MouseListener with IChart.addMouseListener, where the IChart was retrieved using IClientGUI.getChart(). (setting a null mouse listener creates null pointer exceptions) However, I was unsuccessful in overriding the Right-Click mouse event which creates the Popup. Right-Click event is processed (and consume()'d?) already creating the Popup, so that event does not reach my listener's mouseClicked handler. Left and Middle mouse clicks do appear, but the Right mouse event is already handled, (probably consume()'d?) and so does not appear. (Middle mouse button toggles crosshairs, but Middle mouse button event does propagate to my listener.) I tried the following, but the list was empty so could not remove any existing mouse listeners by that method. ichart = iclientGUI.getChart(); List<IChartPanelMouseListener> mouseListeners = ichart.getMouseListeners(); System.out.println("mouseListeners count: "+mouseListeners.size()); for (IChartPanelMouseListener listener : mouseListeners) { if (listener!=null) { ichart.removeMouseListener(listener); } }
Not being an expert on Swing event handling, I'm not quite sure how I can redefine this default behavior of Right Mouse click on an IChart, from creating the Trading Popup, which I want to suppress and eventually redefine myself. I am sure one of you knows how to do this, please. Thanks, HyperScalper
|
|
|
|
|
jlongo
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 09:51
|
|
User rating: 94
Joined: Mon 06 Feb, 2012, 12:22 Posts: 357 Location: Portugal, Castelo Branco
|
|
|
|
|
CriticalSection
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 13:04
|
|
User rating: 70
Joined: Sat 22 Sep, 2012, 17:43 Posts: 118 Location: Brazil, Fortaleza, Ceará
|
I'm in meetings most of the day but will look into this later if it hasn't been resolved by then and if it has delete this post.
My guess is that they're using a JGlassPane off the JRootPane or JInternalFrame or so to trap the entire active area. This would prevent you from intercepting the event at the chart or chartpanel layer.
Events go to the deepest component in the component list by default so absent a glass pane you would have to find the actual component where the listener is located (traverse the Component.getParent() hierarchy starting with e.getSourceEvent().getComponent().getParent() and call getMouseListeners() on each component/parent find). That first .getParent() is important as the component returned by .getComponent() is the chart which already has your own mouselistener registered).
There is a long list of J components that go into organising the GUI. One good lead might be to pick off the MainFrame which is accessbile via IChart if I remember right. Note that the context chart behaviour is active over the WHOLE application frame (effectively) such that if u right click in indicators, the price column, the left dashboard they all react with a context. That is either Frame/GlassPane code in action or each section's root container/component is doing a similar thing.
Hope this makes sense but I'll be back later.
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 13:06
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
Jose, yes, that's exactly what I tried to do. It seems the right mouse click event creates the popup, and is then consumed before it reaches my listener. So the following code is not reached when the right mouse button is clicked, but handles left and middle clicks. @Override public void mouseClicked(IChartPanelMouseEvent e) { try { System.out.println("mouseClicked event button... "+e.getSourceEvent().getButton()+ " BUTTON3 code would be: "+MouseEvent.BUTTON3); // TODO: eventually implement Right Click mouse menu if (SwingUtilities.isRightMouseButton((MouseEvent)e.getSourceEvent())) { // or alternate test... if (e.getSourceEvent().getButton() == MouseEvent.BUTTON3) { // right-click System.out.println("right-click event..."); } } catch(Exception ex) { ex.printStackTrace(); } }
So, the left and middle mouse click events do reach my listener. I am not understanding something here. HyperScalper
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 13:18
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
CriticalSection wrote: Events go to the deepest component in the component list by default so absent a glass pane you would have to find the actual component where the listener is located (traverse the Component.getParent() hierarchy starting with e.getSourceEvent().getComponent().getParent() and call getMouseListeners() on each component/parent find). That first .getParent() is important as the component returned by .getComponent() is the chart which already has your own mouselistener registered).
Thanks CriticalSection, maybe a traversal like that would yield something. I did try using a prior removeMouseListener before adding my listener, but the retrieved listener lists appeared empty. Did not consider .getParent()... Hmmmmm.... HyperScalper
|
|
|
|
|
API Support
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 14:25
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
This will get fixed with next JForex-SDK releases. Please don't attempt to access components which are not part of the API, since the component hierarchy is subject to change with subsequent JForex-SDK releases.
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 18:14
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
API Support wrote: This will get fixed with next JForex-SDK releases. Please don't attempt to access components which are not part of the API, since the component hierarchy is subject to change with subsequent JForex-SDK releases. Is it correct, then, that with API 2.8.0 those who are currently using a custom Right-Click mouse listener will not be able to intercept the Right-Click mouse event? I understand that you are saying I cannot over-ride this default "trading context menu" behavior in v2.8.0 could you please confirm that? HyperScalper
|
|
|
|
|
tcsabina
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Tue 17 Sep, 2013, 19:56
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
Hi, I use the Robot class to fire a fake mouse click, which is necessary to get out from a chart object edit operation. I don't know if that is an option for you to hide the pop-up menu with a mouse click, also don't know if this right-click menu disappears at all with a click, but you could give it a try. But keep in mind this Robot mouse click is also implemented in a mouselistener. That is not clear for me that you are not able to change/modify the mouse listener for the right-click, or you just cannot override it. If you can create another mouselistener, which is called after the one that generates the pop-up, you might have a chance to workaround this, till support fixes this. There is a topic where I explain this Robot class, but haven't found it yet. But of course it is plain simple to use. edit: I've found the topic: viewtopic.php?f=65&t=49420&p=72787#p72787And I fire an Enter key click, not a mouse click, but that's not important.
|
|
|
|
|
CriticalSection
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Wed 18 Sep, 2013, 03:15
|
|
User rating: 70
Joined: Sat 22 Sep, 2012, 17:43 Posts: 118 Location: Brazil, Fortaleza, Ceará
|
FAIR CAUTIONSTICK TO THE PUBLIC APIS AND DOCUMENTED AREAS OF FUNCTIONALITY IF YOU TRULY VALUE THE INTEGRITY OF YOUR CODEBASE. I fundamentally agree with the stance taken by API Support and welcome their positive feedback regarding the issues raised in the initial question. JFC Swing isn't thread safe and nor is any capital a strategy manages once adventure takes us into rocky mountains full of wild surprises. Multiple layers of platform logic in play behind the scenes make it easy to break something if we cross the line so better we get all of our Feature Requests in to Support in time for christmas and hope for the best Spaghetti below is posted specifically for HyperScalper's attention- true spaghetti - comments may not make sense but code straight forward on reading
- Slight typo in the intercepter class (switch around the oldlistener dispatches for Pressed and Released)
- Tested on the Platform but I expect it to work synonymously in the Standalone
- Context menu gone and all events including Button3 pass through to your chart mouse listener ready for your custom menu
Attachments: |
MouseIntercept.java [8.11 KiB]
Downloaded 294 times
|
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on
this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control
on their content. Anyone accessing this webpage and downloading or otherwise making use of any document,
data or information found on this webpage shall do it on his/her own risks without any recourse against
Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from
the use and/or reliance on any document, data or information found on this webpage.
|
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Wed 18 Sep, 2013, 04:00
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
...thanks Critical..... COMPLETELY AGREE. Thanks for the temporary Work-Around suggestions, though... HyperScalper
|
|
|
|
|
API Support
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Wed 18 Sep, 2013, 07:57
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
hyperscalper wrote: I understand that you are saying I cannot over-ride this default "trading context menu" behavior in v2.8.0 could you please confirm that? Yes. This will get fixed.
|
|
|
|
|
hyperscalper
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Fri 27 Sep, 2013, 16:48
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
API Support wrote: hyperscalper wrote: I understand that you are saying I cannot over-ride this default "trading context menu" behavior in v2.8.0 could you please confirm that? Yes. This will get fixed. What version will contain the fix? It's broken my code so I am waiting anxiously HyperScalper
|
|
|
|
|
kurak777
|
Post subject: Re: API 2.8.0 standalone Chart right-click context menu |
Post rating: 0
|
Posted: Sat 12 Oct, 2013, 20:39
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
Hello Support,
Which API version is this issue fixed in?
Thanks and regards, Kurak
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|