Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: XE7 Clipboard - copy and paste text


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Oct 28, 2015 8:30 AM Last Post By: Jerry Dodge
Fergus Dixon

Posts: 16
Registered: 5/10/07
XE7 Clipboard - copy and paste text  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 4, 2014 1:30 PM
We are trying to move a program across from VCL to Firemonkey. With the Clipboard, we have a right click option to save all text from a Listbox to the Clipboard or Paste it into the clipboard.

Not sure how to do this in FireMonkey.

Found this thread http://codeverge.com/embarcadero.delphi.firemonkey/clipboard-text/1041201 but FMX.Platform gives errors in XE7.

Any advise or pointers would be much appreciated.

Edited by: Fergus Dixon on Dec 4, 2014 1:32 PM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: XE7 Clipboard - copy and paste text [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 4, 2014 2:33 PM   in response to: Fergus Dixon in response to: Fergus Dixon
Fergus wrote:


That was how to do it prior to XE4. In XE4, some FMX.Platform functionality
was refactored, where clipboard access is now exposed via a separate IFMXClipboardService
interface:

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Platform.IFMXClipboardService

You have to query for at interface at runtime, eg:

var
  Clipboard: IFMXClipboardService;
  Value: TValue;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, 
IInterface(Clipboard)) then
  begin
    ...
    Value := TValue.From<TypeHere>(DataHere);
    Clipboard.SetClipboard(Value);
  end;
end;


var
  Clipboard: IFMXClipboardService;
  Value: TValue;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, 
IInterface(Clipboard)) then
  begin
    Value := Clipboard.GetClipboard;
    ...
  end;
end;


--
Remy Lebeau (TeamB)
Jerry Dodge

Posts: 1
Registered: 9/19/13
Re: XE7 Clipboard - copy and paste text [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 28, 2015 8:30 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Fergus wrote:


That was how to do it prior to XE4. In XE4, some FMX.Platform functionality
was refactored, where clipboard access is now exposed via a separate IFMXClipboardService
interface:

http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Platform.IFMXClipboardService

You have to query for at interface at runtime, eg:

var
  Clipboard: IFMXClipboardService;
  Value: TValue;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, 
IInterface(Clipboard)) then
  begin
    ...
    Value := TValue.From<TypeHere>(DataHere);
    Clipboard.SetClipboard(Value);
  end;
end;


var
  Clipboard: IFMXClipboardService;
  Value: TValue;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, 
IInterface(Clipboard)) then
  begin
    Value := Clipboard.GetClipboard;
    ...
  end;
end;


--
Remy Lebeau (TeamB)

Ew, that sucks that I have to use RTTI. I always disable RTTI as to not blow up the size of my application, but it seems something as simple as a clipboard requires it.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02