Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic DiagramView.getItemAt() (Read 3437 times)
reedm60
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Oct 31st, 2018
DiagramView.getItemAt()
Nov 17th, 2018 at 12:25am
Print Post  
Does anyone have any examples of using DiagramView.geItemAt(PointF, Boolean, Boolean);?

I call it using the event.getRawX() and event.getRawY() values returned in the MotionEvent object passed into the onTouchEvent(View, MotionEvent) and it never returns the DiagramItem I am touching. 

Do I need to turn some option on or convert the x,y values to some thing else?


Thanks!
  
Back to top
 
IP Logged
 
reedm60
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Oct 31st, 2018
Re: DiagramView.getItemAt()
Reply #1 - Nov 17th, 2018 at 2:43pm
Print Post  
Here is the code for the onTouchEvent

@Override
public boolean onTouchEvent(View v, MotionEvent event) {
      // This line always returns null for 'di'
      DiagramItem di = mDiagramView.getItemAt(new PointF(event.getRawX(), event.getRawY()), true);   
}

Why is the DiagramItem returned from getItemAt() always null?
  
Back to top
 
IP Logged
 
reedm60
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Oct 31st, 2018
Re: DiagramView.getItemAt()
Reply #2 - Nov 18th, 2018 at 3:29pm
Print Post  
Ah ha!  I got it.

If I use event.getX() and event.getY(), it works.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: DiagramView.getItemAt()
Reply #3 - Nov 19th, 2018 at 7:18am
Print Post  
Hi,

I can't see getItemAt method in DiagramView class, is it your custom method? There's Diagram.getItemAt method and it expects coordinates specified in diagram's MeasureUnit, while the View.onTouchEvent override probably gives you Android's device pixels. See if diagram events like DiagramListener.nodeClicked won't work better for you, or otherwise try converting pixels to diagram coordinates using DiagramView.deviceToDoc. You can find an example with deviceToDoc used here -
https://mindfusion.eu/Forum/YaBB.pl?num=1432073553/3#3

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
reedm60
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Oct 31st, 2018
Re: DiagramView.getItemAt()
Reply #4 - Nov 19th, 2018 at 4:06pm
Print Post  
Thank you.  I meant Diagram.getItemAt() not DiagramView.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint