Dukascopy
 
 
Wiki JStore Search Login

API 2.8.0 standalone Chart right-click context menu
 Post subject: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 00:11 
User avatar

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

Image


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.
 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 01:09 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 04:47 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 09:51 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi hyperscalper:

Have you tried to add a mouse listener to the chart panel and capture the event ?

https://www.dukascopy.com/wiki/#Chart_Op ... e_listener.

Trade well

JL


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 13:04 
User avatar

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.


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 13:06 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 13:18 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 14:25 
User avatar

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.


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 18:14 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Tue 17 Sep, 2013, 19:56 
User avatar

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#p72787
And I fire an Enter key click, not a mouse click, but that's not important.


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Wed 18 Sep, 2013, 03:15 
User avatar

User rating: 70
Joined: Sat 22 Sep, 2012, 17:43
Posts: 118
Location: Brazil, Fortaleza, Ceará
FAIR CAUTION
STICK 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.
 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Wed 18 Sep, 2013, 04:00 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Wed 18 Sep, 2013, 07:57 
User avatar

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.


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Fri 27 Sep, 2013, 16:48 
User avatar

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


 
 Post subject: Re: API 2.8.0 standalone Chart right-click context menu Post rating: 0   New post Posted: Sat 12 Oct, 2013, 20:39 
User avatar

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


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com