cancel
Showing results for 
Search instead for 
Did you mean: 

Draw a dotted rectangle.

Zwei.9
Associate III

How to draw a dotted rectangle while dragging to select a part of the interface?

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi,

The cheapest way is to do this using images (which can be handled by DMA2D), rather than using Canvas lines.

Overwrite the handleClickEvent() method in your view to be able to superimpose your selection rectangle and subsequently select elements on the screen based on the position of that rectangle. Listen for a drag event - If this is registered start drawing the rectangle and when a clickevent is of type RELEASED, then remove the rectangle and evaluate what to do based on the area covered by it.

For the rectangle itself, implement it in a custom container that can expand from a certain point based on finger position. Use more containers inside to act as a "viewport" that shows more and more of the "dotted line" the more the container grows (and vice versa) based on finger origin and x,y delta.

Let me know if you need some more ideas.

/Martin

View solution in original post

1 REPLY 1
Martin KJELDSEN
Chief III

Hi,

The cheapest way is to do this using images (which can be handled by DMA2D), rather than using Canvas lines.

Overwrite the handleClickEvent() method in your view to be able to superimpose your selection rectangle and subsequently select elements on the screen based on the position of that rectangle. Listen for a drag event - If this is registered start drawing the rectangle and when a clickevent is of type RELEASED, then remove the rectangle and evaluate what to do based on the area covered by it.

For the rectangle itself, implement it in a custom container that can expand from a certain point based on finger position. Use more containers inside to act as a "viewport" that shows more and more of the "dotted line" the more the container grows (and vice versa) based on finger origin and x,y delta.

Let me know if you need some more ideas.

/Martin