Tag: firemonkey

Detect special keys from physical keyboard on iOS

I'm trying to detect special keys in my Delphi iOS app using an external keyboard, a Smart Keyboard for iPad in my case. Every key that is also present in the OS virtual keyboard works perfectly.. but everything else doesn't. My goal is to detect when the user press "special" keys, like: Shift Control Option (alt) Command Arrow keys Tab I made a simple test app using this method for open the keyboard on a generic TFMXObject uses FMX.VirtualKeyboard, FMX.Platform; procedure ShowKey(AControl: TFMXObject); var LKeyboardService: IFMXVirtualKeyboardService; begin LKeyboardService := nil; if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService, LKeyboardService) then begin LKeyboardService.ShowVirtualKeyboard(AControl); end; end; I tried to catch the KeyDown and KeyUp event on the form, on the TFMXObject called by that function, on a generic TEdit, but the event is never called for those special keys (except for arrow up and arrow down when a TEdit is selected) I already read the documentation about the KeyDown event, but the event is not called at all for those keys What can i do to detect KeyDown and KeyUp event for every possible key? Thank you!
Read More

Has support of Firemonkey for Android ended with SDK 25?

I have Delphi CE 10.3.3 and make first experiences with device independant development of Firemonkey. The sample project NativeControlsDemo runs on a Huawei LLD-L31 smartphone with Android 28 very good (32 and 64 Bit). But my Samsung Galaxy M31 is not recognized by Delphi (not shown in the device list). The Samsung runs Android 30. The debugger options are activated and I can successful debug with Android Studio. Android SDK 25.2.5 is the latest version in the target configuration. Why is my Samsung not usable? Does Firemonkey not support newer Android versions? For new applications is the lifecycle very important. New features of hardware and OS should be supported from the development system as soon as possible and maintained as long as possible.
Read More

Wrong exe icon in windows explorer when using resource file

I have an FMX application created in RAD studio 10.4 and have set the main icon in Project Options, Icons. I have also added 2 additional icons in the resource file using Resources and Images, which will be used by an installer to create file associations. All icons are 32x32 pixels. The main icon appears correctly in the application title bar but not in Windows explorer. It always takes the first of the 2 additional icons in the resource file. At first I thought this could be due to windows caching of icons but it is not. I'm using software called icofx to extract the icons from the exe and I see that the main icon always appears last. I have tried changing the identifiers in Resources and images with the same result. The identifiers shown in icofx are not the ones I set. I've also tried renaming the additional icons so that they're last alphabetically, but that doesn't work either. If I try the same with an old Delphi 7 project then it always results in the main application icon appearing first, which is what I want. Any ideas?
Read More

How to use styled map in TMapView

I use RAD Studio 10.4.1 and have a TMapView component on my Android app. No problem with the TMapView, it works well. On Google Plateform I see that we can styling maps https://developers.google.com/maps/documentation/javascript/styling Thats what I do, I add a plan and a styled map in my Google Cloud Plateform. To use it on web page we need to do this call : <script src="https://maps.googleapis.com/maps/api/jskey=API_KEY&map_ids=MAP_ID&callback=initMap"> </script> On my app, I have the API_KEY on "Version information" : apiKey=MY_MAPS_API_KEY I try to add the MAP_ID in the manifest but he don't care : <meta-data android:name="com.google.android.maps.v2.MAP_ID" android:value="xxxxx" /> How can I use the TMapView with my Map ID ?
Read More

Melbourne Meeting – March 2021

Monday 15 March at 6 for 6:15pm start. ONLINE MEETING – WE WILL NOT BE MEETING IN PERSON We will meet online, instead of meeting at the Shed. At this meeting, Grahame Grieve from Health Intersections will present his experiences converting from a FMX application to an LCL application that runs on Windows, Linux and OSX using Lazarus and discuss what bits have worked well, and what hasn’t.… Continue reading ›
Read More

Launch an external application from a button click [closed]

I have an application developed with Delphi FMX, I need to display a list of stores with their address and I want to launch an external application "Google maps" from my local application from a button click when i choose the store, can I do that, and if so, how? thanks to @Remy Lebeau: On Android, you need to create an Intent object describing the app you want to run, and then pass that Intent to SharedActivity.startActivity(). On iOS, you need to pass a URL string for the target app to SharedApplication.openUrl(). You will have to {$IFDEF} your code accordingly
Read More

How to draw freehand on TPaintBox (or any other control)?

I am trying to make a signature pad with Delphi 10.3 FMX. My understanding is that I should handle the OnMouseMove event, first setting coordinate in the OnMouseDown event, and then use the DrawLine() method. So far I managed this: unit HeaderFooterFormwithNavigation; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Graphics, FMX.Forms, FMX.Dialogs, FMX.TabControl, System.Actions, FMX.ActnList, FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Edit; type THeaderFooterwithNavigation = class(TForm) ActionList1: TActionList; PreviousTabAction1: TPreviousTabAction; TitleAction: TControlAction; NextTabAction1: TNextTabAction; TopToolBar: TToolBar; btnBack: TSpeedButton; ToolBarLabel: TLabel; btnNext: TSpeedButton; TabControl1: TTabControl; TabItem1: TTabItem; TabItem2: TTabItem; BottomToolBar: TToolBar; pb1: TPaintBox; edt1: TEdit; edt2: TEdit; edt3: TEdit; procedure FormCreate(Sender: TObject); procedure TitleActionUpdate(Sender: TObject); procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure pb1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); procedure pb1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); private { Private declarations } public { Public declarations } end; var HeaderFooterwithNavigation: THeaderFooterwithNavigation; _lastPoint: TPointF; implementation {$R *.fmx} {$R *.LgXhdpiPh.fmx ANDROID} {$R *.iPhone4in.fmx IOS} procedure THeaderFooterwithNavigation.TitleActionUpdate(Sender: TObject); begin if Sender is TCustomAction then begin if TabControl1.ActiveTab <> nil then TCustomAction(Sender).Text := TabControl1.ActiveTab.Text else TCustomAction(Sender).Text := ''; end; end; procedure THeaderFooterwithNavigation.FormCreate(Sender: TObject); begin { This defines the default active tab at runtime } TabControl1.First(TTabTransition.None); end; procedure THeaderFooterwithNavigation.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if (Key = vkHardwareBack) and (TabControl1.TabIndex <> 0) then begin TabControl1.First; Key := 0; end; end; procedure THeaderFooterwithNavigation.pb1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin _lastPoint.X := X; _lastPoint.Y := Y; end; procedure THeaderFooterwithNavigation.pb1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); var thisPoint: TPointF; brush: TStrokeBrush; begin if pb1.Canvas.BeginScene then try pb1.Canvas.Stroke.Thickness := 2; pb1.Canvas.Stroke.Kind := TBrushKind.Solid; pb1.Canvas.Stroke.Color := TAlphaColors.Black; thisPoint.X := X; thisPoint.Y := Y; pb1.Canvas.DrawLine(_lastPoint, thisPoint, 1); _lastPoint := thisPoint; finally pb1.Canvas.EndScene; end; end; end. When I run it on my mobile (Android) and press on its screen, the whole screen becomes black. Why is that? How can I make simple freehand drawing app?
Read More

TImageViewer , change position after zoom in/out

I'm using a TImageviewer component in my app, build with DELPHI 10.4, FMX framework If I change the Zoom level the viewport is automatically changed back to the image center and I have to move again to the position I want to view using a high / lower zoom level. How to ban this behavior of the TImageViewer? If I have my mouse e.g. somewhere in the lower-left area of my image and I start zooming, This mouse point should become the new center point of the zoomed view, can I improve the TImageview here also?
Read More

Delphi FMX et OpenStreetmap

I want to add a map in my application that contains a list of nearby stores. I wanted to integrate OpenStreetMap but I don't know where to start, even when I tried to add the TWebBroweser component and i put the url" www.openstreetmap.org" i don't have a result, and i tried to make a html url OpenStreetMapsPage: AnsiString = '<html> '+ '<head> '+ '<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" /> '+ '<script src="http://www.openlayers.org/api/OpenLayers.js"></script> '+ '<script type="text/javascript"> '+ ' function initialize() '+ '{'+ ' map = new OpenLayers.Map("map_canvas");'+ ' map.addLayer(new OpenLayers.Layer.OSM()); '+ ' var lonLat = new OpenLayers.LonLat( [Lng] , [Lat] ) '+ ' .transform( '+ ' new OpenLayers.Projection("EPSG:4326"), '+ ' map.getProjectionObject() '+ ' ); '+ ' var zoom=16; '+ ' var markers = new OpenLayers.Layer.Markers( "Markers" ); '+ ' map.addLayer(markers); '+ ' markers.addMarker(new OpenLayers.Marker(lonLat)); '+ ' map.setCenter (lonLat, zoom); '+ '}'+ ''+'</script> '+ '</head> '+ '<body onload="initialize()"> '+ ' <div id="map_canvas" style="width:100%; height:100%"></div> '+ '</body>'+ '</html>'; and nothing, someone can help me please and thank you
Read More

Deploying to iPad os 14.4 – 2nd device refused to deploy

I'm using the free developer account from Apple can only deploy in Development mode. I deployed to one iPad. I've another device with exact 14.4 version, but on 2nd device it always hangs after the PAServer calls the "iosinstall" executable... it'll just show "Launching..." in Delphi for the longest time until it times out minutes later. 1st iPad deploys to device in about 1 minute. Is there a way to find out what exact PAServer is stuck on? (I already have verbose on) Restarts do not seem to solve the problem. The same 2nd device works great with XCode with the exact same provisioning. Any ideas? UPDATE on 9 Mar 2021 : I realised there is a Dec2020 Apple patch for 10.4.1. Patched up. Still does not work. Scenario : 3 pieces of iOS 14.4 devices (2 ipads and 1 iPhone). 1st piece (iPad) can install both Actual Project and Small Sample Project. 2nd piece (iPhone) can only install only Small Sample Project. 3rd piece (iPad) cannot install both Actual and Small Sample. It seems weird! iOS all using 14.4 Using Delphi 10.4.1 with Dec'20 Apple patch
Read More

How to have my own App folder for images that can be accessed through Photo gallery official iOS (Delphi/Firemonkey)

I'm developing an App that can create their own images. That images I want to save to an own and local folder (like WhatsApp and others App), but I need that local folder can be accessed from Photos official iOS app (like WhatsApp, DJI...). Please, how I can create my own folder to save and get images from my App, and that folder can be accessed from gallery of iOS? It is probably not very difficult because this method is used by many applications, but I have been looking for 5 days and I can not find anything. Thanks in advance!!
Read More

FMX and TMediaplayer playing several audio files

I am converting a Windows game to FMX 2D. Several audio files for music effects have to play asynchronous. With Windows Mediaplayer and VCL it was running very good. Now with Windows Mediaplayer unexspected C5 errors sometimes occur. Therfore I tried the TMediaplayer from FMX. But this player is not eligable, because the game does not run smoothly. It jerks when music effects are played. It seems the main thread is used. The logic for starting music effects runs in a separate thread. In Windows Mediaplayer it is running very good. Asynchronous playback of music effects is essential for a game. I cannot understand why a relatively new component is not suitable for this. I haven't found a solution on the internet. Is there any component that offers FMX the appropriate features for this case? This is a sample program to demonstrate FMX MediaPlayer with Threads: unit Unit1; // Demo pgm to demonstrate FMX MediaPlayer using Threads, written by Peter Kloß interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts, FMX.ListBox, FMX.Media; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; ListBox1: TListBox; LoadButton: TButton; PlayButton: TButton; MoveButton: TButton; Timer1: TTimer; procedure LoadButtonClick(Sender: TObject); procedure PlayButtonClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; type TMsgRecord = record Filename : string; end; var Form1: TForm1; implementation {$R *.fmx} ThreadVar msgPtr : ^TMsgRecord; function PlayMusic(Parameter: Pointer): Integer; var MediaPlayer: TMediaPlayer; begin Result := 0; MediaPlayer := TMediaPlayer.Create(Application); msgPtr := Parameter; MediaPlayer.FileName := msgPtr.Filename; MediaPlayer.Play; repeat sleep(5); Application.ProcessMessages; until MediaPlayer.State <> TMediaState.Playing; //MediaPlayer.Free; // leads to C5 error in FMX at end of pgm FreeMem(msgPtr); EndThread(0); end; procedure TForm1.LoadButtonClick(Sender: TObject); begin if OpenDialog1.Execute then ListBox1.Items.AddStrings(OpenDialog1.Files); end; procedure TForm1.PlayButtonClick(Sender: TObject); var id: LongWord; thread: Integer; msg: ^TMsgRecord; begin if ListBox1.ItemIndex < 0 then exit; GetMem(msg, Sizeof(TMsgRecord)); msg.Filename := ListBox1.Items[ListBox1.ItemIndex]; thread := BeginThread(nil, 0, Addr(PlayMusic), msg, 0, id); //CloseHandle(thread); end; procedure TForm1.Timer1Timer(Sender: TObject); begin if MoveButton.Tag = 0 then begin MoveButton.Position.X := MoveButton.Position.X - 1; if MoveButton.Position.X = 0 then MoveButton.Tag := 1; end else begin MoveButton.Position.X := MoveButton.Position.X + 1; if MoveButton.Position.X = Form1.Width - MoveButton.Width then MoveButton.Tag := 0; end end; end. On Form1 there are 2 buttons. One for loading filenames into Listbox1. And one Play button. When Play button is clicked, a thread is started which creates a MediaPlayer and plays the sound given by parameter filename. To see the influence to the programs main activity there is a MoveButton sliding from left to right and vice versa on Form1. For that Timer1 is used, fired every 15 msecs. One can see (and hear) when several sounds are started and playing parallel. The sound should take some seconds so that overlapping occurs and the negative effect is noticeable.
Read More