Paste clipboard sous android

papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 - Modifié le 16 déc. 2021 à 09:17
papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 - 16 déc. 2021 à 17:24
Bonjour,
j'ai une procedure comme celle-ci
{$IFDEF ANDROID}
   if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc)
  then
  begin

    Value := Svc.GetClipboard;
    if not Value.IsEmpty then
    begin
    { 
         //teste passage, ok  value n'est pas vide
      s := 'InsertPictureFromClipBoard not Value.IsEmpty';

      TDialogservice.MessageDialog(s, TMsgDlgType.mtConfirmation,
        [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0,
        procedure(const AResult: TModalResult)
        begin
          Reply := AResult;
        end);
      if Reply <> mrYes then
           }
        if Value.IsType<TBitmapSurface> then
          try
            Bitmap := TBitmap.Create;
            try
              Bitmap.Assign(Value.AsType<FMX.Surfaces.TBitmapSurface>);
              Image1.Bitmap := Bitmap;
            finally
              Bitmap.Free;
            end;
          finally
            Value.AsType<FMX.Surfaces.TBitmapSurface>.Free;
          end;
    end;

qui marche sous fmx windows mais pas sous android. la copie vers image1 ne se fait pas.
il semblerait que le problème soit ici
if Value.IsType<TBitmapSurface>
et je sais pas par quoi le remplacer. le type serait différent sous android que sous windows???
si une bonne âme qui passe par là a une idée je suis preneur.:)


1 réponse

Cirec Messages postés 3833 Date d'inscription vendredi 23 juillet 2004 Statut Modérateur Dernière intervention 18 septembre 2022 50
16 déc. 2021 à 11:20
Bonjour,

voici ce que dit Embarcadero à ce sujet

...
Windows, macOS and iOS platforms provide copy/paste of both text and images. The Android clipboard does not support images. To allow users to copy and paste images between your own Android applications, you can use a custom format instead.
...

procedure TCopyPasteDemo.CopyButtonClick(Sender: TObject);
var
  Svc: IFMXClipboardService;
  Image: TBitmap;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc) then
    if TextRadioButton.IsChecked then
      Svc.SetClipboard(Edit1.Text)
    else
    begin
      Image := TextBorder.MakeScreenshot;
      try
        Svc.SetClipboard(Image);
      finally
        Image.Free;
      end;
    end;
end;

procedure TCopyPasteDemo.PasteButtonClick(Sender: TObject);
var
  Svc: IFMXClipboardService;
  Value: TValue;
  Bitmap: TBitmap;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc) then
  begin
    Value := Svc.GetClipboard;
    if not Value.IsEmpty then
    begin
      if Value.IsType<string> then
      begin
        PasteLabel.Text := Value.ToString;
        PasteImage.Bitmap := nil;
      end
      else if Value.IsType<TBitmapSurface> then
      try
        PasteLabel.Text := string.Empty;
        Bitmap := TBitmap.Create;
        try
          Bitmap.Assign(Value.AsType<TBitmapSurface>);
          PasteImage.Bitmap := Bitmap;
        finally
          Bitmap.Free;
        end;
      finally
        Value.AsType<TBitmapSurface>.Free;
      end;
    end;
  end;
end;



Cordialement,
0
papyvore Messages postés 223 Date d'inscription samedi 15 novembre 2003 Statut Membre Dernière intervention 16 décembre 2021 15
16 déc. 2021 à 17:24
salut merci de cette réponse
j'ai vu cet exemple. Sur tablette dans l'onglet paste pour le texte ok, mais pour image je reçois (TBitmap@C9....)
je suppose l'adresse .C'est la que je coince je ne sais pas quel format personnalisé mettre à la place.
Ou plutôt je ne sais personnaliser le format.
0
Rejoignez-nous