🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
9 messages
9 total messages Started by Jos� Wed, 28 Feb 2007 17:35
Dragging from TEdit
#2403
Author: Jos�
Date: Wed, 28 Feb 2007 17:35
13 lines
1160 bytes
I try to drag data from a TEdit control to another TEdit. How is this
done?

The events MouseUp and MouseDown are fired, but both are fired by the
TEdit where I started dragging, even if I release the button somewhere
else. (Appears to be a nasty bug)

More events are fired if I set DragMode to dmAutomatic, but this makes
it impossible to focus a control to enter text.

Please help.
-- 
Jos�
Re: Dragging from TEdit
#2409
Author: DreamChaser
Date: Thu, 01 Mar 2007 00:57
16 lines
1636 bytes
Jos� wrote:
> The events MouseUp and MouseDown are fired, but both are fired by the
> TEdit where I started dragging, even if I release the button somewhere
> else. (Appears to be a nasty bug)
> 
> More events are fired if I set DragMode to dmAutomatic, but this makes
> it impossible to focus a control to enter text.
> 
It looks like you will need to set the drag manually. In the MouseDown 
of the Edit1 set the drag mode to true, in the MouseOver of Edit2 allow 
accepting, and in the DragDrop (I think) of Edit 2 do your data 
manipulation.

This is off the top of my head, but I think it will get you looking in 
the right direction.
DC
Re: Dragging from TEdit
#2411
Author: Jos�
Date: Thu, 01 Mar 2007 09:19
21 lines
1852 bytes
On Wed, 28 Feb 2007 18:57:25 -0600, DreamChaser <jkofsky@No-Spam.net>
wrote in borland.public.cppbuilder.nativeapi:

>> The events MouseUp and MouseDown are fired, but both are fired by the
>> TEdit where I started dragging, even if I release the button somewhere
>> else. (Appears to be a nasty bug)
>> 
>> More events are fired if I set DragMode to dmAutomatic, but this makes
>> it impossible to focus a control to enter text.
>> 
>It looks like you will need to set the drag manually. In the MouseDown 
>of the Edit1 set the drag mode to true, in the MouseOver of Edit2 allow 
>accepting, and in the DragDrop (I think) of Edit 2 do your data 
>manipulation.

The compiler complains if I set DragMode to a Boolean. Besides, it
makes it impossible to edit data. But worse, your suggestion seems to
imply that the program must know in advance whether the user intends
to drag from Edit1 to Edit2 or the other way around.
-- 
Jos�
Re: Dragging from TEdit
#2421
Author: DreamChaser
Date: Thu, 01 Mar 2007 22:41
62 lines
3030 bytes
Jos� wrote:
>> It looks like you will need to set the drag manually. In the MouseDown 
>> of the Edit1 set the drag mode to true, in the MouseOver of Edit2 allow 
>> accepting, and in the DragDrop (I think) of Edit 2 do your data 
>> manipulation.
> 
> The compiler complains if I set DragMode to a Boolean. Besides, it
> makes it impossible to edit data. But worse, your suggestion seems to
> imply that the program must know in advance whether the user intends
> to drag from Edit1 to Edit2 or the other way around.

 From BCB Help Files:
void __fastcallTFMForm::FileListBox1MouseDown(TObject *Sender,
   TMouseButton Button, TShiftState Shift, int X, int Y)
{
   if (Button == mbLeft)	// drag only if left button pressed
   {
     TFileListBox *pLB = (TFileListBox *)Sender; // cast to TFileListBox
     if(pLB->ItemAtPos(Point(X,Y), true) >= 0) // is there an item here?
       pLB->BeginDrag(false);                   // if so, drag it
   }
}

void __fastcallTForm1::TreeView1DragOver(TObject *Sender, TObject *Source,

   int X, int Y, TDragState State, bool &Accept)
{
   if (Source->InheritsFrom(__classid(TFileListBox)))
     Accept = true;
}

void __fastcall TForm1::TreeView1DragDrop(TObject *Sender, TObject *Source,
int X, int Y){

   if (Source->InheritsFrom(__classid(TFileListBox)))
   {
     TTreeNode *pNode = TreeView1->GetNodeAt(X,Y); // pNode is drop target
     AnsiString NewFile = pNode->Text + AnsiString("/") +
       ExtractFileName(FileList->FileName); // build file name for drop 
target
     MoveFileEx(FileList->FileName.c_str(), NewFile.c_str(),
       MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); // move the file
   }
}


What does all this mean:

Edit1OnMouseDown
	Edit1->BeginDrag(true);

Edit2DragOver
	if (Source == Edit2) { Accept = true; }

Edit2DragDrop
	Edit2->Text = Edit1->Text;

There are things about the mouse cursor that you also need to do 
manually but I'm unable to remember all at this time. But look up 
drag-drop operations in the Help files.

DC
Re: Dragging from TEdit
#2425
Author: Jos�
Date: Fri, 02 Mar 2007 09:58
15 lines
1316 bytes
On Thu, 01 Mar 2007 16:41:26 -0600, DreamChaser <jkofsky@No-Spam.net>
wrote in borland.public.cppbuilder.nativeapi:

>Edit1OnMouseDown
>	Edit1->BeginDrag(true);
>
>Edit2DragOver
>	if (Source == Edit2) { Accept = true; }
>
>Edit2DragDrop
>	Edit2->Text = Edit1->Text;

Yesss! That worked. Thanks.
-- 
Jos�
Re: Dragging from TEdit
#2437
Author: Jos�
Date: Sat, 03 Mar 2007 20:51
29 lines
1845 bytes
On Thu, 01 Mar 2007 16:41:26 -0600, DreamChaser <jkofsky@No-Spam.net>
wrote in borland.public.cppbuilder.nativeapi:

>What does all this mean:
>
>Edit1OnMouseDown
>	Edit1->BeginDrag(true);
>
>Edit2DragOver
>	if (Source == Edit2) { Accept = true; }
>
>Edit2DragDrop
>	Edit2->Text = Edit1->Text;

Some things I discovered:
1. The Accept =true is not really needed.
2. It is up to me what to have in the DragDrop method.

In fact, I simply want to select a number of consecutive controls.
This happens in DradOver, and I do not really need DragDrop.

One problem has remained:
The DoubleClick method opens a dialogbox. When this box is closed, the
event MouseDown occurs again, and the system seems to think that the
mouse is down. IOW a drag operation has started although the mouse
button is up. I must click again to  tell the system that the mouse is
up.
-- 
Jos�
Re: Dragging from TEdit
#2438
Author: DreamChaser
Date: Sun, 04 Mar 2007 03:21
25 lines
2101 bytes
Jos� wrote:
> 
> Some things I discovered:
> 1. The Accept =true is not really needed.
> 2. It is up to me what to have in the DragDrop method.
> 
> In fact, I simply want to select a number of consecutive controls.
> This happens in DradOver, and I do not really need DragDrop.
> 
> One problem has remained:
> The DoubleClick method opens a dialogbox. When this box is closed, the
> event MouseDown occurs again, and the system seems to think that the
> mouse is down. IOW a drag operation has started although the mouse
> button is up. I must click again to  tell the system that the mouse is
> up.

Accept in the destination control may be involved if DragDrop is 
automatic. (I have used DragDrop very much) Also I can't help with the 
DblClick business. But at least you have most of it working. I just 
noticed that now had answered your OP, and I had a little experience 
with it...So there you go :)

Let us know if you fix the above "problems."

DC
Re: Dragging from TEdit
#2439
Author: Jos�
Date: Sun, 04 Mar 2007 09:48
30 lines
2328 bytes
On Sat, 03 Mar 2007 21:21:42 -0600, DreamChaser <jkofsky@No-Spam.net>
wrote in borland.public.cppbuilder.nativeapi:

>> One problem has remained:
>> The DoubleClick method opens a dialogbox. When this box is closed, the
>> event MouseDown occurs again, and the system seems to think that the
>> mouse is down. IOW a drag operation has started although the mouse
>> button is up. I must click again to  tell the system that the mouse is
>> up.

>Let us know if you fix the above "problems."

Well, I fixed them, and the result is satisfying, although it is not
what I originally intended.

My screen contains TEdit controls with the following data:
[sequence number] [data] [data] [data]
[sequence number] [data] [data] [data]
etc.
The sequence numbers are read only, it does not accept keyboard input.
I wanted to select a numer of lines by dragging from any control to
any other control (in a different line). The result was that is was
harder to edit a data field. 
For example, I could no more select a word within a field, and as I
told you, double clicking a field (which opened a modal dialog box)
caused unexpected trouble.
I solved the problem by applying the drag events only the the first
field of each row, with the sequence number. This field is read only.
-- 
Jos�
Re: Dragging from TEdit
#2280
Author: DreamChaser
Date: Tue, 20 Mar 2007 03:34
9 lines
1460 bytes
> 
> Some things I discovered:
> 1. The Accept =true is not really needed.
I was just re-reading this post and I think that the Accept=true is 
probably just for changing the icon to indicate to the user that they 
can drop it. I could be wrong on this, but every example that I have 
seen says to do it :)

dc
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads