|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
Listen to chart object selection |
kurak777
|
Post subject: Listen to chart object selection |
Post rating: 0
|
Posted: Sat 16 Nov, 2013, 20:04
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
I added custom context menu to chart (thru IChart#addMouseListener). It shows up when I press and release right button mouse. The issue is: it suppresses show up of IChartObject menu when it is selected.
Can you please add new method to IChart: isChartObjectSelected() so that I know there is a chart object selected and I should suppress my context menu?
Can we continue in this thread or should I start new one?
Thank and best regards, Kurak
|
|
|
|
 |
tcsabina
|
Post subject: Re: Suppress trading popup menu in Standalone API. |
Post rating: 1
|
Posted: Mon 18 Nov, 2013, 12:59
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
Hi Kurak, There is a selected() method available for chart objects, within the chartObjectListener. Check this wiki page. I am not sure if you can overload it for the default chart objects of the platform, but if it is possible, maybe you can use a global flag, or something, to indicate that there is an object on the chart, selected. If this is completely not relevant to the problem you face, I am sorry to talk about something useless  .
|
|
|
|
 |
kurak777
|
Post subject: Re: Listen to chart object selection |
Post rating: 0
|
Posted: Tue 19 Nov, 2013, 20:54
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
Your message is definitely relevant.
Can you please tell me more about your idea of overloading the default chart objects?
At first glance I see here a lot of work. In order to listen to chart object select I would have to add a listener to every chart object present on the chart and listen on chart itself if there is a new chart object added to add a listener to it. Seems to be complicated but maybe you have simpler solution on your mind?
At the same time I believe core of IChartObject already has such property (boolean selected) implemented and I wish Dukascopy would open the interface for it.
Thank you and best regards, Kurak
|
|
|
|
 |
API Support
|
Post subject: Re: Listen to chart object selection |
Post rating: 0
|
Posted: Thu 21 Nov, 2013, 16:35
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Consider doing something like this: @Override public void onStart(final IContext context) throws JFException { this.console = context.getConsole(); final Set<IChartObject> listenerAdded = new HashSet<IChartObject>(); Runnable periodicTask = new Runnable() { public void run() { for(final IChart chart : context.getCharts()){ for(final IChartObject o : chart.getAll()){ if(listenerAdded.contains(o)){ continue; } listenerAdded.add(o); o.setChartObjectListener(new ChartObjectAdapter(){ @Override public void selected(ChartObjectEvent e) { console.getInfo().println("selected " + o + " on chart of feed" + chart.getFeedDescriptor()); } }); } } } };
executor.scheduleAtFixedRate(periodicTask, 0, interval, timeUnit); }
@Override public void onStop() throws JFException { executor.shutdown(); }
Attachments: |
ListenersForAllChartObjects.java [2.74 KiB]
Downloaded 131 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.
|
|
|
|
|
 |
kurak777
|
Post subject: Re: Listen to chart object selection |
Post rating: 0
|
Posted: Sun 24 Nov, 2013, 22:51
|
|
User rating: 7
Joined: Fri 13 Jan, 2012, 20:49 Posts: 94 Location: Poland, Warsaw
|
Hi,
Thank you for the idea. It is definitly working solution however I am afraid about performance. Running this code every 200ms on platform with several opened charts full of IChartObjects may be resorce consumable.
So I will try again and ask if it is possible to add a method IChart#isAnyChartObjectSelected() or IChartObject.isSelected(), or should I forget about it?
Best regards, Kurak
|
|
|
|
 |
tcsabina
|
Post subject: Re: Listen to chart object selection |
Post rating: 0
|
Posted: Mon 25 Nov, 2013, 08:23
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
Hi,
I would run some test, before concerning performance problems. There are not too many chart objects on on chart, aren't there? It could be a dozen, maybe? Maybe more, but definitely not hundreds of object on one single chart, right? If you have 20 charts open (which is also a bit overkill, as who can monitor more then 5 charts?), we are still talking about 100-200 objects to iterate through. That should not be a problem, I think
Of course, your requested methods are more elegant, but till it is available (if it ever will be?), just test and try what support provided.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|