Jump to content

jarto

Administrators
  • Content count

    212
  • Joined

  • Last visited

About jarto

  • Rank

  • Birthday 02/11/1970

Profile Information

  • Gender
    Male
  • Location
    Dubai

Business

  • Company name
    Karkkimala Consulting Oy
  • Sector
    Information technology

Smart Mobile Studio

  • Edition
    Enterprise

Recent Profile Visitors

204 profile views
  1. Errors in editBox

    Thank you for reporting these. I need to find a way to reproduce the Object Inspector bug. When I test the Android.css -theme, I don't seem to have any problems entering text in editboxes. Do you have a test project that you could attach?
  2. Paint box

    When it comes to saving and sending the data, I suppose something like this works: SaveButton.OnClick:=procedure(Sender: TObject) begin var FImg := TW3Image.Create(Self); FImg.SetBounds(0,0,FCanvas.Width,FCanvas.Height); FImg.LoadFromImageData(FCanvas.Canvas.ToImageData); FImg.ToStream(YourStreamWhereYouWantTheImageDataToBeSaved); end;
  3. Paint box

    When it comes to drawing the signature, here's a quick example based on the featured demo called "Multi Finger Paint": unit Main; interface uses System.Types, System.Colors, SmartCL.System, SmartCL.Controls, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms; type TPaintBoxForm = class(TW3form) private FCanvas: TW3GraphicControl; FMouseDown: boolean; FMouseID: integer; FPrevX: integer; FPrevY: integer; protected procedure InitializeObject; override; procedure FinalizeObject; override; procedure HandleMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer); procedure HandleMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer); procedure HandleMouseUp(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer); procedure Paint(Sender: TObject; canvas: TW3Canvas); procedure PaintLine(X, Y: integer); procedure Resize; override; procedure StyleTagObject; override; end; implementation procedure TPaintBoxForm.FinalizeObject; begin FCanvas.Free; inherited; end; procedure TPaintBoxForm.InitializeObject; begin inherited; FCanvas := TW3GraphicControl.Create(Self); FCanvas.OnPaint := Paint; FCanvas.OnMouseDown := HandleMouseDown; FCanvas.OnMouseMove := HandleMouseMove; FCanvas.OnMouseUp := HandleMouseUp; FCanvas.SimulateMouseEvents := True; FPrevX:=-1; FPrevY:=-1; end; procedure TPaintBoxForm.HandleMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer); begin FMouseDown := True; PaintLine(X, Y); end; procedure TPaintBoxForm.HandleMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer); begin if FMouseDown then PaintLine(X, Y); end; procedure TPaintBoxForm.HandleMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: integer); begin FMouseDown := False; Inc(FMouseID); FPrevX:=-1; FPrevY:=-1; end; procedure TPaintBoxForm.Paint(Sender: TObject; Canvas: TW3Canvas); begin FCanvas.Canvas.FillStyle := '#FFFFFF'; FCanvas.Canvas.FillRectF(0, 0, Width, Height); end; procedure TPaintBoxForm.PaintLine(X, Y: Integer); begin if (FPrevX>=0) and (FPrevY>=0) then begin FCanvas.Canvas.BeginPath; FCanvas.Canvas.MoveToF(FPrevX,FPrevY); FCanvas.Canvas.LineToF(X,Y); FCanvas.Canvas.StrokeStyle := ColorToWebStr(ClBlack); FCanvas.Canvas.Stroke; end; FPrevX:=X; FPrevY:=Y; end; procedure TPaintBoxForm.Resize; begin FCanvas.SetBounds(0, 0, Width, Height); FCanvas.Invalidate; end; procedure TPaintBoxForm.StyleTagObject; begin inherited; StyleClass := 'TW3CustomForm'; end; end.
  4. Scroll form

    There are a few ways you can do this: Easiest is to just set NativeScrolling := True on the form. After that it just scrolls the whole form automatically, if the full contents are not visible. If you don't want the whole form to scroll, you can build all the scrollable contents inside a ScrollBox. Here you have two possibilities: TW3NativeScrollBox or TW3ScrollBox. If you use TW3ScrollBox, make sure to create the contents inside it's content (MyCtrl := TWhatever.Create(ScrollBox.Content) and to call ScrollBox.UpdateControl when content is built and resized. The difference between the "native" solutions and TW3ScrollBox is, that TW3ScrollBox does all the scrolling with code, which lets you control everything better.
  5. JSON Post

    Something like this: uses ... SmartCL.Net.Http, System.Codec.Url, System.JSON; type ... TMyJsonCommand = record Command: String; Table: String; Code: String; end; ... procedure SendAndReceiveExample; var JsonToSend: TMyJsonCommand; begin var httpcli := TW3HttpRequest.Create; httpcli.OnDataReady := procedure(Sender: TW3HttpRequest) var JsonData: Variant; begin JsonData := TJson.parse(Sender.ResponseText); WriteLn('Code received: '+JsonData.Code); WriteLn('Name received: '+JsonData.Name); end; httpcli.Open('POST','https://example.com:8082/wherever.it.is'); httpcli.RequestHeaders['Content-type']:='application/x-www-form-urlencoded'; JsonToSend.Command := 'Open'; JsonToSend.Table := 'Client'; JsonToSend.Code := 'XXXX'; httpcli.Send('json='+TURLCodec.Encode(TJson.stringify(JsonToSend))); end; And if you get this to work locally but not on mobile devices, you solve it on your server side by adding the necessary CORS headers.
  6. This happened because you created the app (of saved it) with the beta-version. You need to follow the beta-channel when it comes to updates too. We are only updating the alpha-channel to keep it up with the development. But as we are now in the beta-stage, the beta-channel is the one to follow and use until the real 3.0 release is done.
  7. Alpha and beta channels should currently give the same versions, except the IDE version numbers are different. The TryStrToInt was moved along with a few other conversion releated functions to System.Types.Convert. This was done to slim down System.Types, so that WebWorkers would get a lot smaller. TryStrToInt itself was not the reason, but other converting functions like base64. @IElite Can you zip and send me the project, so I can have a look?
  8. Google Maps API

    I did e-mail you the zip-file. Didn't you get it?
  9. More updates are available with SmartUpdate. To update, do this: Delete Projects\Features Demos\API\WebWorker -folder Run SmartUpdate This is because the old WebWorker demo was moved to a Timer- subfolder and a new one was created. The new demo is made as an example how applications created with Smart Mobile Studio can scale nicely by using multiple threads and cores. To run the demo: Open and compile the Worker-project under Projects\Features Demos\API\WebWorker\Count Primes Open and run the Main Application Example: CPU load. First spike is with 8 threads, then 2 threads and last 4 threads.
  10. Using WriteLn in WebWorkerThread

    At the moment: asm console.log("Hello world!"); end; I'll move WriteLn to System.Types.
  11. Web Workers calling javascript

    That secondary js that you call is not any hand crafted js. At the moment you can already write it as a separate Smart Mobile Studio WebWorker project. What I think you are asking here, is to be able to write the code in a normal class or unit, which the compiler would then compile as a WebWorker to a separate js file?
  12. A new update is available with SmartUpdate. This fixes bugs in WebWorkers.
  13. WebWorker demo

    This is also fixed now. Just use SmartUpdate to update.
  14. This seems to work: procedure TForm1.W3GoogleMaps1MapCreated(Sender: TObject); var aPath: Array of JLatLngLiteral; p1,p2: JLatLngLiteral; PLOptions : JPolylineOptions; PL : TGoogleMapsPolyline; begin PLOptions.map:= W3GoogleMaps1.Map; PLOptions.strokeColor:= 'red'; PLOptions.strokeWeight:= 2; PLOptions.strokeOpacity:= 1.0; PLOptions.geodesic:= true; PLOptions.visible:= true; p1.lat := 43.974382; p1.lng:= -74.426716; aPath.Add(p1); p2.lat:= 44.9734854; p2.lng:= -72.4239453; aPath.Add(p2); PLOptions.path := aPath; PL := new TGoogleMapsPolyline(PLOptions); end; JPolylineOptions = record property clickable: boolean; property draggable: boolean; property editable: boolean; property geodesic: boolean; property map: TGoogleMap; property path: array of JLatLngLiteral; property strokeColor: String; property strokeOpacity: Float; property strokeWeight: Integer; property visible: Boolean; property zIndex: integer; end; TGoogleMapsPolyline = partial class external 'google.maps.Polyline' public Constructor Create(options : JPolylineOptions); external 'Polyline'; path: array of JLatLngLiteral end;
  15. @IElite You set this before the map is created: PLOptions.map:= W3GoogleMaps1.Map; Try to do all the path stuff after OnMapCreated has been triggered. Great code guys. Gotta ask again: Do you mind if I extend the current map control using your code?
×