Jump to content

Magno

Members
  • Content Count

    62
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Magno


  1. I guess title says all, I put a TEdit/TMemo on a form, copy text from any source, and after by using the Control-V it won't paste, but of course if I right click a standard popup shows up and I can paste. Is possible to make the FMX controls to accept it? I can intercept the keyboard, test if the data is text, populate the text control, at first shot it will change the value of the control, not wanted behavior at all, like the popup it should fill at the caret/cursor position. Am I forgetting something here?

     


  2. My program should run with Linux, when connecting to MySQL, using Firedac, I am having the error below:
     

    Error: [FireDAC][Phys][MySQL]-314. Cannot load vendor library [/usr/lib/x86_64-linux-gnu/libmysqlclient.so]. Hint: check it is in the PATH or application EXE directories, and has x64 bitness.

     

    The message is sent by my own program, here I attempt to load the lib and having this issue. I had a similar issue when working with MacOS but I was able to fix it. The software is the same I have running with MacOS. Any tips on what I could check? I am running Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-105-generic x86_64)

     

    I followed every single step from https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Connect_to_MySQL_Server_(FireDAC)

     


  3. 11 hours ago, programmerdelphi2k said:

    you can use the RestDebuger with your url + params, etc... after send your command, the RestDebugger receive the response (right or not)... after this, you can copy the objects and paste it in your form and see how all was done... you got it?

    Yes, but for that I would to be sure the TRESTRequest is doing the exactly thing the Rest debuger does. I will follow this.


  4. I need to send for the Google's support how my program is sending the request for it's API but I have only the parameters. I need that because my lib to use Programmable Search Engine is working but I am getting different results from when in the public search https://cse.google.com using my own parameters (using credentials you can search and use as a test too). So I need that information, if possible. If not possible, by using the Delphi's REST Debugger I could be sure that the TRESTRequest is doing the same?

     

     


  5. Hi all,

     

    I followed this link https://docwiki.embarcadero.com/RADStudio/Sydney/en/Connect_to_MySQL_Server_(FireDAC) but I couldn't find that libmysqlclient.dylib file. The files which comes with the package are completely different. That Embarcadero's link is already outdated.

     

    This is the 1st time I am trying to create a MacOS program that requires using of MySQL connection. I am creating a CLI program and attached a data module, so at OnCreate I am doing that:

     

    {$IFDEF MSWINDOWS}
       FDPhysMySQLDriverLink1.VendorLib := '.\libmysql.dll';
    {$else}
       FDPhysMySQLDriverLink1.VendorLib := '/usr/local/mysql-connector-c++-8.0/lib64/libmysqlcppconn.dylib';
    {$ENDIF}

    I am not sure if that's the way I can change the vendor in runtime, anyway I have no error when running with Windows, however besides not be able to understand what is the correct dylib to MacOS, as I told before, there isn't any libmysqlclient.dylib file.

     

    I am running a Mac with OS Ventura.


  6. Hi! Well I am struggling on this, maybe it's late and I am tired enough, I'd appreciate any help with. Below my function:
     

    type
      TReadings = record
        Time: Integer;
        Flex: Boolean;
        Message: String;
    end;  
    
    function GetReadings: TReadings;
    var
       JSonObject: TJSONObject;
       JSonValue: TJSonValue;
       JsonArray: TJSONArray;
       ArrayElement: TJSonValue;
       s: string;
    begin
       Result.Message := '';
       Result.Time := 0;
       Result.Flex := false;
       // example of a json
       s := '{"A":0,"B":0,"C":1,"D":0,"K":{"T":"X","acc":81,"max":116},"result":[{"type":{"TP":30.3,"message":'+
            '"Added successfuly"},"time":503,"flex":"yes"}]}';
    
       JSonValue := TJSonObject.ParseJSONValue(s);
       JsonArray := JSonValue.GetValue<TJSONArray>('result');
    
       for ArrayElement in JsonArray do
        // how do I could read message, time and flex values?
    
       JSonValue.Free;
    end;

    I need to read that 3 values inside the array. So far I can move the array into the JsonArray but I don't know how to extract the values. Of course I could made a string parse and solve the issue, but I am will be glad if I can fix it using that Json classes to populate the result record.

     

    Again, thanks for any help.


  7. 3 hours ago, aehimself said:

    Result:

    image.thumb.png.c16f1feb251a0d10847cabc1fcdb797a.png

     

    The code was written in D11 but I tried to keep it as simple as possible. I hope D4 supports the below calls...

     

    Worked like a charm!!! I didn't though using arrays lol.. I love programming because of this! I will convert back to my real code. I just want to check all the behavior, but so far so good.

     

    Thank you very much for you time!!

     

    3 hours ago, aehimself said:

     

     


  8. I am attaching a simple functional demo I just did with the code I am using. It has 3 buttons, one to select the source node, other to the destination (target) and the copy button itself.

    I works fine, but not if you try to copy a "father" node into it's on child, no problem to copy into another branch, like the 2nd image in the initial message here.

     

    I am really happy if you can help me because I am struggling for about 2 days on it, maybe a technique to make the node "understand" where it should stop when it's into the same branch, because only seeing if the node is nil isn't enough as by the recursive method we will have always something to iterate with this specific case and it will blow the memory. Maybe casting a class into the Data, or mark its pointer memory address, I dunno what could be the best. I am still trying something here.

    CopyTreeView.rar


  9. Yes, Delphi 4.... Let's go, if you can help.

     

    I have a tree view with some nodes, like below

     

    image.png.5e9aaade8305355d178b14a39e1f9e74.png

     

    I need to, eg., copy the select node (1.1.1) into 1.1.1.2 !

    image.png.125b85a30c3738e30a1db7662a1bcdea.png

     

    I've trying to figure out how to accomplish this. I already have a copy/past function that works well if no such complex copy is required, like copy a top node into a lower child node. The recursive function goes crazy with this lol

     

    I found some solutions but mostly will use newer version of Delphi so it won't work.  One of the solutions I found was that:

    https://www.swissdelphicenter.ch/en/showcode.php?id=1876

     

    But it won't allow me to copy into the same branch from a top level.

     

    I would appreciate any help on this!

     


  10. On 3/30/2022 at 1:03 PM, corneliusdavid said:

    OK, I finally see what you're getting at. I got sidetracked by just the idea of simple editing of text on a mobile device and missed part about the ControlType--sorry. (I had recently experienced frustration when typing a long text and trying to view/edit the whole thing--and that was using the phone's built-in text messaging app--I thought that's where this was going.)

     

    I ran a sample project and switched the ControlType property of the TEdit between Styled and Platform and now see what you've been trying to explain. Yes, the "Platform" control works properly but (and as explained on docwiki) does not respect the z-order. 

     

    So, yeah, it does look like a bug, or incomplete feature implementation, in the styled version of the TEdit.

    Nice! That's exactly the issue. So when user enter the edit I change to Platform, he lefts I change back to Platform, as a workaround.


  11. 14 hours ago, corneliusdavid said:

    Have you tried other apps on Android that have a small text edit input to compare how they act? @Lars Fosdaldescribes how it can be done on Android--and yes, that works but I have problems getting it right so more often just backspace or don't even try to scroll. Same thing on iOS.

    Normally other apps would use different frameworks from FMX. This very app I am creating, as I already told, will work when changing the ControlStyle to Platform, but if I do it one of the issues is related to z control, like bellow:

     

    Screenshot_20220330-092905.jpg


  12. On 3/29/2022 at 1:32 AM, Lars Fosdal said:

    On Android, you should be able to move the caret to the right by tapping and dragging?

    Not working, you got trapped into the visible text. Want to change a word/letter beyond the visible part? Delete back some characters... 


  13. On 3/28/2022 at 9:18 PM, corneliusdavid said:

    Right. That's typical on a mobile device--it's not specific to Delphi apps. Basically, you can type forward or backspace to clear it out and type it over. That's why I sometimes hook a Bluetooth keyboard up to my mobile device when I'm writing lots of text--I can use the keyboard arrow keys to navigate past the beginning/end of the visible text.

     

    Have you ever sent a long text message with a phone? It's a pain if you've been typing fast then look at what you've typed and realized there's a misspelled word in the middle and you have to somehow select it and type over without losing it or finger-swipe to go back to the top of the paragraph to make sure you didn't miss anything.

     

    You could set the MaxLength property of the TEdit so the user can't type a bunch of text; or use a TMemo and make it fill up the screen so the user can see all the text they've typed.

     

    Welcome to mobile development!!

    Well I agree but in this case it will work fine when changing the Style to Platform, so this can be a very specific issue with FMX.

     


  14. 2 hours ago, corneliusdavid said:

    Are you referring to the lack of left/right/home/end buttons, or just the standard user interface on a mobile device? 

     

    I've never had problems with TEdit text scrolling on mobile devices--I just hook up a Bluetooth keyboard if I want to be able to move the cursor through the text.

    I don't know about lack of buttons, but I meant about the inability to move the cursor/caret allowing the user to edit any text he already typed in. You can only fix the text you "see" in the control at that time.

     

    Suppose the user need to type "Lorem ipsum dolor sit amet, consectetur adipiscing elit":

     

    Lorem ipsum |dolor sit amet, consectetur adip|iscing elit

     

    The green text between the two pipes | represents the width of the TEdit. So if the cursor is over the letter r and the user needs to fix a test beyond this space it's impossible, unless he deletes the text using backspace, the gray text is out of range because there is no visible cursor to allow moving to that text.

     


  15. I am using Delphi 10.4.2 CE, also downloaded the trial version of Alexandria and the results are the same:

     

    1. Put a TEdit into the form, aligned or not, target to mobile

    2. Type in some words until you cross the visible borders, so the text will scroll...

    3. Try returning to the beginning of the text! 

     

    If you can do it without get blocked into the visible part of the control, please let me know how to! I can't move the cursor beyond the visual limits.

     

    If you change to Platform mode it will work as it should, but you will lose the Z level for the controls.

     

    InkedScreenshot_20220328-165934_LI.jpg


  16. Well, I quit trying to doing it myself and now I am using Kastri lib (https://github.com/DelphiWorlds/Kastri) I works like a charm!!

     

    The second part is about receiving a text from another app, like a selected text. I already can do it, but just if I close my app and so the event will be triggered. Once I change to other app, select text and share, it won't work. I was guessing if OnActive should solve that but no, it's never triggered again, same onShow, only onPaint but that's crazy. Is there another way once my Android application returns focus to me check the intent? I tried implement the Brain Long solution (http://blong.com/Articles/DelphiXE7NFC/NFC.htm#ReceivingIntents) but I was unable to.. 😞


  17. Well, reading an answer at Stackoverflow (https://stackoverflow.com/questions/56952411/sharing-image-and-link-through-intent-for-whatsapp-telegram-etc) is said:

    Quote

    The definition of "correctly" is up to the developers of those other apps, not you. What they do with the extras on your Intent is up to them, not you. What they do with those extras will vary based on the app, the app version, and possibly device/OS characteristics. You have no control over any of that. You simply provide the data and let the developers of the other apps do what they want with it.

    So, as I thought, now if I really need to send to Telegram I must figure out how to correctly input the information there. At least the sharing file is working.


  18. I just tried Intent.setType(StringToJString('image/* text/plain')), well the result is the same. At very first I tried Intent.setType(StringToJString('text/plain')) and it will be used because the type file is ascii text. Maybe Telegram can have another way to receive a text file, which is different from Whatsapp.


  19. 7 hours ago, Cristian Peța said:

    And what if you omit this line?

    
    Intent.setPackage(StringToJString('com.whatsapp'))

    It will open the share sheet so I could choose what app to share with. Now, if I select WhatsApp it works, if I select Telegram I receive the "unsupported content" message. For some reason Telegram wont accept the same parameters used for WhatsApp. Testing with Signal won't even return an error, it at least let me select a contact.

     

    I think the something is still missing here. So far I could not find any answer. The reason I am specifying that target intent for WhatsApp is because not all app could receive a sharing, and for email it is a kind different.

     


  20. Ok, I finally did something, at least. Now I can share files with WhatsApp, but it will fail to Telegram or other apps that could receive a file:

    procedure TForm1.ShareFile(const FileName: String);
    Var
    {$IFDEF ANDROID}
       Intent: JIntent;
       FileUri: Jnet_Uri;
       ListArqs: JArrayList;
    {$ENDIF}
    begin
    {$IFDEF ANDROID}
       
       ListArqs := TJArrayList.Create;
       FileUri := TJNet_Uri.JavaClass.fromFile(TJFile.JavaClass.init(StringToJString(FileName)));
       ListArqs.Add(0, FileUri); // if intend to send more file change the index (default 0)
       try
          Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_SEND);
          Intent.setType(StringToJString('image/text/plain'));
          Intent.putParcelableArrayListExtra(TJIntent.JavaClass.EXTRA_STREAM, ListArqs);
          Intent.setPackage(StringToJString('com.whatsapp'));
          // Intent.setPackage(StringToJString('org.telegram.messenger'));
          Intent.addFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
          SharedActivity.startActivity(TJIntent.JavaClass.createChooser(Intent, StrToJCharSequence('')));
       except
          on E: Exception do
             ShowMessage(E.Message);
       end;
    {$ENDIF}
    end;

     


  21. On 2/26/2021 at 7:11 PM, Magno said:

    I read almost every topic of the internet about this, but no clue and actually I have 2 issues... My Android app, Delphi CE, needs to save a file into the shared folder and it works fine (using TPath.GetSharedDocumentsPath), but I need to eventually share it and here I have the issues, first my app can't touch that file for sharing, but I can read and write it perfectly. The error is that known " android.os.FileUriExposedException: file:///storage/emulated/0/Documents/myfile.txt exposed beyond app through ClipData.Item.getUri()".

     

    Ok, so I thought that my app can read the file I could clone a copy into the "sandbox" (TPath.GetDocumentsPath) and try to share and this is my second issue, because it seems to save the copy there but when I try to check the folder in phone the path .../files is empty. My Android is running the version 11 and SDK 26.

     

    The sharing function I am using can be the issue, of course:

    
    procedure ShareFile(FileName: string);
       Intent: JIntent;
       fileuri: JParcelable;
       Uri, Data: Jnet_Uri;
    begin
       Intent := TJIntent.Create;
       Intent.setAction(TJIntent.JavaClass.ACTION_SEND);
       Intent.addFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);
       Data := TJnet_Uri.JavaClass.parse(StringToJString(FileName));
       Intent.setType(StringToJString('vnd.android.cursor.dir/*'));
       fileuri := JParcelable(TJnet_Uri.JavaClass.fromFile(TJFile.JavaClass.init(StringToJString(FileName))));
       Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM, fileuri);
       TAndroidHelper.Activity.startActivity(Intent);
    end;

    I am not even sure if the vnd is correct. If someone could help I would be very glad.

    Edit: I still didn't find any solution, but the code bellow seems to be "more" correct, I replicate from similar in Java but the message now is like "invalid format", as I am trying to share a text file to WhatsApp, eg. Bellow the new code:

     

       if FileExists(FileName) then
       begin
          Intent := TJIntent.Create;
          Intent.setAction(TJIntent.JavaClass.ACTION_SEND);  Intent.setType(StringToJString('*/*'));
          Intent.putExtra(TJIntent.JavaClass.EXTRA_STREAM,  StringToJString('content://'+FileName));
          SharedActivity.startActivity(TJIntent.JavaClass.createChooser(Intent, StrToJCharSequence('Share with...')));
       end;
    Quote

     

     

×