Marquee Selection

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Marquee Selection

Postby smd » Thu Nov 19, 2015 1:27 pm

Firemonkey RAD 10 (C++)

I am trying to figure out how to code a mouse marquee selection of various graphical objects. Assume some text or other graphical objects (rectangle, circle,...) on a canvas. I want to simply hold down the left mouse button and drag a selection rectangle to select various objects. Like how a graphics editor program or text editor works where I can select by dragging the cursor selection rectangle across the desired text or objects.

I am trying to figure out how to write the code to do such. I went through the help menu and examples which shows how to draw the objects and do various transformations on the objects, but I cannot find any information how to implement a mouse marquee selection.

Does anyone know of a tutorial, video, example, or something that explains how to do such on a Firemonkey canvas?
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas

Re: Marquee Selection

Postby rlebeau » Fri Nov 20, 2015 8:16 pm

Untested, but in theory maybe you can use a TRectangle for that.

1. Have an OnMouseDown event create a new TRectangle object. Put it on top of whichever graphic container you are clicking on. Set the TRectangle.Fill.Kind property to TBrushKind.None to make its background transparent. Set the TRectangle.Stroke properties to make the border appear how you want. Also save the mouse position as an anchoring point for reference.

2. Have an OnMouseMove event reposition/resize the TRectangle relative to the anchoring point as needed.

3. Have an OnMouseUp event select whatever objects are within the TRectangle's client area as needed, and then free the TRectangle.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
BCBJ Author
BCBJ Author
Posts: 1560
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Return to Technical

Who is online

Users browsing this forum: Lena and 16 guests