Recent

Author Topic: Help: Drop text to TMemo from another Application  (Read 8677 times)

OH1KH

  • Jr. Member
  • **
  • Posts: 63
Help: Drop text to TMemo from another Application
« on: March 28, 2018, 05:28:15 pm »
HI !
I need help for simple thing that I can not make work, and do not found any (right words?) solution with search.

I have Tmemo with some text. Say  it has "Hello".
I paint word "world" from another App and drag and drop it over Tmemo.

Tmemo will then have text "Helloworld".

But I want that dropping erases "hello" and leaves just "world".
I have tried several ways:
OnDrop (Tmemo.Clear)
OnMouseOver(select all, but if drag is on no selection is made, otherwise yes)
ONMouseUP .... and so on.

Is there even any way to do "ReplaceOnDrop" with linux/gtk2 ?
--
Saku

OH1KH

  • Jr. Member
  • **
  • Posts: 63
Re: Help: Drop text to TMemo from another Application
« Reply #1 on: April 01, 2018, 12:37:29 pm »
Hi!
Seems that that nobody does know solution for this! Over 200 times read, with no suggestions at all.

One way to go around this is to paint text in other program, NOT drag it, place cursor over TMemo and press mouse wheel button.
In that way at least my Fedora26/LXDE erases the old text and drops the painted text in TMemo.

But that is a work around, not solution.
 
--
Saku

wp

  • Hero Member
  • *****
  • Posts: 11831
Re: Help: Drop text to TMemo from another Application
« Reply #2 on: April 01, 2018, 01:01:22 pm »
Can't you call Memo.SelectAll in the OnDragDrop code as first statement?

balazsszekely

  • Guest
Re: Help: Drop text to TMemo from another Application
« Reply #3 on: April 01, 2018, 01:59:14 pm »
Quote
Seems that that nobody does know solution for this! Over 200 times read, with no suggestions at all.
Perhaps people are busy with other things...

Quote
But that is a work around, not solution
You have an OnDropFiles event(Form1) just clear the memo there and you're good to go:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);
  2. begin
  3.   Memo1.Clear;
  4. end;

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Help: Drop text to TMemo from another Application
« Reply #4 on: April 01, 2018, 02:17:28 pm »
You can't do this with lazarus onboard functions/components.
Look at the gtk2 documentation.
On  Windows you can use  drag&drop components from A.Melander look here https://forum.lazarus.freepascal.org/index.php?topic=38761.0.

@people
I think he means dragging text from another text application(i.e. gedit) and dropping on his application to the Tmemo.

« Last Edit: April 01, 2018, 02:19:19 pm by Soner »

balazsszekely

  • Guest
Re: Help: Drop text to TMemo from another Application
« Reply #5 on: April 01, 2018, 02:23:33 pm »
Quote
@people
I think he means dragging text from another text application(i.e. gedit) and dropping on his application to the Tmemo.
That's exactly what I did. Just select some text in gedit then drag-drop it to a memo. The lazarus application thinks you're dropping files, this is why my solution works(see above).

OH1KH

  • Jr. Member
  • **
  • Posts: 63
Re: Help: Drop text to TMemo from another Application
« Reply #6 on: April 01, 2018, 03:32:05 pm »
Hi !

TForm1.FormDropFiles does not work. Dropping does not clear previous content.
As well as  Memo.SelectAll does not do it.

So it seems that mouse wheel button is the only way. (linux/gtk2)
--
Saku

balazsszekely

  • Guest
Re: Help: Drop text to TMemo from another Application
« Reply #7 on: April 01, 2018, 03:39:12 pm »
It works for me on Linux mint. I can make a video if you like. What is your system?

OH1KH

  • Jr. Member
  • **
  • Posts: 63
Re: Help: Drop text to TMemo from another Application
« Reply #8 on: April 02, 2018, 09:25:29 am »
Fedora26/LXDE
--
Saku

balazsszekely

  • Guest
Re: Help: Drop text to TMemo from another Application
« Reply #9 on: April 02, 2018, 09:36:32 am »
Unfortunately I don't have Fedora so I cannot test. I have one more question though. Does Form1 FormDropFiles triggered when you drag-drop something over the memo?

OH1KH

  • Jr. Member
  • **
  • Posts: 63
Re: Help: Drop text to TMemo from another Application
« Reply #10 on: April 02, 2018, 05:50:59 pm »
Yep it triggers.

And If I create a new program with just form and memo (or edit). It works as you say.
But If I try that on my old program it does not work.

I have now make a bigger study where the difference is. It is just similar Edit, but program has several forms and it might be some kind of parent/child issue.

Thanks anyway.
Now I know that it is somehow possible and I can keep on trying.
--
Saku

 

TinyPortal © 2005-2018