Skip to main content
Zwei.9
Associate III
September 2, 2019
Solved

Draw a dotted rectangle.

  • September 2, 2019
  • 1 reply
  • 747 views

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

This topic has been closed for replies.
Best answer by Martin KJELDSEN

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

1 reply

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
September 2, 2019

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