Recent

Author Topic: OnMouseDown - BeginDrag for custom tbitbtn?  (Read 1885 times)

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
OnMouseDown - BeginDrag for custom tbitbtn?
« on: October 10, 2017, 03:35:33 pm »
I'm creating a custom button based on tbitbtn on form create.

I do it because I need to add some properties to use with drag and drop.

But I can't figure out how to set BeginDrag true on mousedown.

In the examples I found it looks like this:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.DragonButtonMouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   if Button = mbLeft then
  5.     DragonButton.BeginDrag(true);
  6. end;
  7.  

Nothing spectacular going on there, but how do I get the same effect for my custom button?

Code: Pascal  [Select][+][-]
  1.   mc := MyClass.Create(self);
  2.   mc.Parent := GroupBox1;
  3.   mc.bob := 'bla';
  4.   mc.Caption := 'test';
  5.   mc.Top := 90;
  6.  

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: OnMouseDown - BeginDrag for custom tbitbtn?
« Reply #1 on: October 10, 2017, 05:01:56 pm »
Drag and drop is already built in to LCL controls. You don't need to add anything to make use of that functionality.
What control are you wanting to drag, and what control are you wanting to drop it onto, and what effect do you then want to see?

"Button" in an OnMouseDown handler refers to one of the buttons on your mouse, not to a BitBtn control. Or is it an actual BitButton that you want to drag and drop onto something?

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: OnMouseDown - BeginDrag for custom tbitbtn?
« Reply #2 on: October 10, 2017, 06:40:25 pm »
I have two TGroupBoxes, one empty and one with two TBitBtn's

One is the normally created TBitBtn, and the other is generated by me by extending the TBitBtn to add the bob property.

What I want to do is add properties to a TBitBtn and use those extra properties when it's dragged and dropped somewhere.

My goal is to use the button to represent an item in a visual designer for web development, so I need to know the "type" of item (row, container, paragraph, etc.) and other info, so the target of the dropped item knows what to do with it.

For example, text items can only be dropped in containers of various kinds, not in each other, not outside of containers, not inside images, and so on.

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: OnMouseDown - BeginDrag for custom tbitbtn?
« Reply #3 on: October 10, 2017, 07:35:38 pm »
I just figured it out   :)

I have to rush out the door, but I'll write a follow up later on, explaining how in case someone else could use the info.

 

TinyPortal © 2005-2018