Jump to content

Czar

Members
  • Content Count

    445
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by Czar

  1. Since the latest RTL alpha the fxMoveby method has a very undesirable side effect. During the tween process the graphic is drawn in the right place. When the tween is complete the image drops by one pixel. See gif for effect. This does not occur in previous SMS 2.2.x.x

     

    numberworksnwords.com/cloud/temp/imgdrop.gif

     

     

     

            var FeedbackInst:= tw3image.create(self);
            FeedbackInst.zindex:=2;
            FeedbackInst.setbounds(-19,25,30,30);
            FeedbackInst.OnLoad:=procedure (sender:TObject)
              Begin
                w3_setstyle(FeedbackInst.Handle,'-webkit-transition','opacity 0.5s ease-in'); //webkit
                w3_setstyle(FeedbackInst.Handle,'transition','opacity 0.5s ease-in'); //mozilla
                FeedbackInst.AlphaBlend:=True;
              end;
            FeedbackInst.loadfromurl('res/ballGreen.png');
            FeedbackInst.fxMoveBy(60,0, 1);

     

    testimg.sproj

  2. There are quite a few IDE related bugs. Here is one:

    1. Drop down two TW3buttons. Double click one - a method is created.
    2. Copy the method name into the second button.
    3. Double click that second button and you will receive an error. COntinue.
    4. Now a second method is created with the same name. 

     

     

  3. I have implemented a simple server using TIdHTTPServer in Delphi 10.0

    in SMS I have the following. This setup works if I use the internal browser. But it fails if I use Firefox or Chrome. I have opened the firewall so the port 8091 is not blocked.

    I cannot figure out why it works with the internal browser but it fails when using external browser.

      W3Memo1.clear;
      FHttp := TW3HttpRequest.Create;
      FHttp.OnDataReady := HandleDataReady;
      FHttp.OnError := HandleError;
    
      fHTTP.Get('http://localhost:8091?file=QPool1.json')

    The OnError does fire but I can't get any details out of it apart from Error 0.

     

    Here is the Delphi code using indy TIdHTTPServer and a memo. The server is bound to 127.0.0.1 port 8091 and it is active

    unit tcpserver;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdContext, IdBaseComponent, IdComponent, IDSync, IdURI,
      IdCustomTCPServer, IdTCPServer, Vcl.StdCtrls, IdCustomHTTPServer, IdHTTPServer;
    
    type
      TForm4 = class(TForm)
        Memo1: TMemo;
        IdHTTPServer1: TIdHTTPServer;
        Button1: TButton;
        procedure IdHTTPServer1CommandGet(AContext: TIdContext;
          ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
        procedure IdHTTPServer1Connect(AContext: TIdContext);
        procedure IdHTTPServer1Disconnect(AContext: TIdContext);
        procedure Button1Click(Sender: TObject);
      private
    
        { Private declarations }
      public
        { Public declarations }
      end;
    
    
    
    var
      Form4: TForm4;
    
    implementation
    
    {$R *.dfm}
    
    
    procedure TForm4.Button1Click(Sender: TObject);
    begin
    memo1.Clear;
    end;
    
    procedure TForm4.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
    IdHTTPServer1.Active := false;
    end;
    
    procedure TForm4.IdHTTPServer1CommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    var
      name, value: string;
      I: integer;
      f : Tstringlist;
    begin
      memo1.Lines.Add('ok'+ ARequestInfo.Params.Text);
      for i := 0 to ARequestInfo.Params.Count-1 do
      begin
        Name := ARequestInfo.Params.Names[i];
        Value := ARequestInfo.Params.ValueFromIndex[i];
    
        AResponseInfo.ResponseNo := 200;
        AResponseInfo.ContentType := 'application/json';
    
        if (Name = 'file') and (fileexists('c:\temp\'+value)) then
        begin
          f := Tstringlist.Create;
          try
           f.LoadFromFile('c:\temp\'+value);
           AResponseInfo.ContentText := f.text;
           memo1.Lines.Add('AResponseInfo.ContentText set');
          finally
           f.Free;
          end;
        end;
      end;
    end;
    
    procedure TForm4.IdHTTPServer1Connect(AContext: TIdContext);
    begin
     memo1.Lines.Add('connected');
    end;
    
    procedure TForm4.IdHTTPServer1Disconnect(AContext: TIdContext);
    begin
    
     memo1.Lines.Add('disconnected');
    end;
    
    end.

     

    Here is the SMS application which simply has a button and a memo on the form

    unit Form1;
    
    interface
    
    uses 
      System.Types,
      System.Types.Convert,
      System.Objects,
      System.Time,
      SmartCL.System,
      SmartCL.Time,
      SmartCL.Graphics,
      SmartCL.Components,
      SmartCL.FileUtils,
      SmartCL.Forms,
      SmartCL.Fonts,     smartcl.net.http,
      SmartCL.Theme,
      SmartCL.Borders,
      SmartCL.Application, SmartCL.Controls.Button, SmartCL.Controls.Memo;
    
    type
      TForm1 = class(TW3Form)
        fHTTP : TW3HttpRequest;
        procedure W3Button1Click(Sender: TObject);
      private
        {$I 'Form1:intf'}
        procedure HandleDataReady(Sender: TW3HttpRequest);
        procedure HandleError(Sender: TW3HttpRequest);
        function  HandleTimeOut : TNotifyEvent;
      protected
        procedure InitializeForm; override;
        procedure InitializeObject; override;
        procedure Resize; override;
      end;
    
    implementation
    
    { TForm1 }
    
    procedure TForm1.W3Button1Click(Sender: TObject);
    begin
      W3Memo1.clear;
      FHttp := TW3HttpRequest.Create;
      FHttp.OnDataReady := HandleDataReady;
      FHttp.OnError := HandleError;
      //FHttp.OnTimeout := HandleTimeOut;
    
      writeln('GET http://localhost:8091?file=QPool1.json');
      fHTTP.Get('http://localhost:8091?file=QPool1.json')
    end;
    
    procedure TForm1.HandleError(Sender: TW3HttpRequest);
    begin
      W3Memo1.add('ERROR: ' + fhttp.Status.ToString + ' ' + fhttp.StatusText + 'With Response: ' + fhttp.ResponseText);
    end;
    
    function TForm1.HandleTimeOut : TNotifyEvent;
    begin
    end;
    procedure TForm1.HandleDataReady(Sender: TW3HttpRequest);
    begin
      W3Memo1.add('HandleDataReady > '#13);
      W3Memo1.add(Sender.ResponseText);
    
    //  fHTTP.free;
    end;
    
    procedure TForm1.InitializeForm;
    begin
      inherited;
      // this is a good place to initialize components
    end;
    
    procedure TForm1.InitializeObject;
    begin
      inherited;
      {$I 'Form1:impl'}
    end;
     
    procedure TForm1.Resize;
    begin
      inherited;
    end;
     
    initialization
      Forms.RegisterForm({$I %FILE%}, TForm1);
    end.

     

     

     

  4. For much of our SMS software we will be using it not only online but also on a desktop where it runs inside a embedded chromium host application. This works really well for us as it allows us to merge the HTML5 software with our win32 software and the kids don't notice that there is something fundamentally different between the two types of applications.

    The challenge is when we need to load a text or JSON file from the res folder. It doesn't work. I am looking for alternatives.

    I remember Jon using images as a file system but I cannot find that post/article.

    How else could I store data (questions for the students etc) locally and still be able to access it?

     

    edit: currently looking at using an indyserver (idTCPserver) on my delphi host application and have SMS application talk to it

     

     

     

  5. I  believe I have a solution that appears to work. Simply bump up the v value

     

      if w3_getIsAndroid then
       TW3Storage.LoadCss('res/app.css?v=1', procedure (const FromUrl: string;
          const ObjectHandle: THandle; const Success: boolean)
      begin
        if success then
        begin
          writeln("Force CSS loading android");
        end;
      end);

     

  6. I have stripped the problem right down and my conclusion is that on android and responsive the click event is firing twice setting the button back to its original setting.

     

    I have included ms since previous click code and the image below slows that a second event fires 2ms later.

     

    unit Form1;
    
    interface
    
    uses 
      System.Types,
      System.Types.Convert,
      System.Objects,
      System.Time,
      SmartCL.System,
      SmartCL.Time,
      SmartCL.Graphics,
      SmartCL.Components,
      SmartCL.FileUtils,
      SmartCL.Forms,
      SmartCL.Fonts,
      SmartCL.Theme,
      SmartCL.Borders, system.time,
      SmartCL.Application, SmartCL.Controls.Button;
    
    type
      TMyButton = class(tw3button)
      public
        checked : boolean;
        Clicked : integer;
        procedure CheckBoxClick(Sender: TObject);
        procedure InitializeObject; override;
       end;
    
    type
      TForm1 = class(TW3Form)
      private
        {$I 'Form1:intf'}
      protected
        procedure InitializeForm; override;
        procedure InitializeObject; override;
        procedure Resize; override;
      end;
    
    implementation
    
    { TForm1 }
    
    procedure TMyButton.InitializeObject;
    begin
      inherited;
      Checked := False;
      Self.OnClick := CheckBoxClick;
      SetBounds(100,200,120,40);
      clicked := GetMilliseconds;
    end;
    
    
    procedure TForm1.InitializeForm;
    begin
      inherited;
      // this is a good place to initialize components
      var MyButton := TMyButton.create(self);
    end;
    
    procedure TMyButton.CheckBoxClick(Sender: TObject);
    begin
      writeln(GetMilliseconds-TMyButton(Sender).Clicked);
      if GetMilliseconds-TMyButton(Sender).Clicked <1000 then
        begin
          writeln('too quick');
          exit;
        end;
    
      if TMyButton(Sender).Checked then begin           // On
        caption := 'not checked';
        Checked := False;
        clicked := GetMilliseconds;
      end
      else begin
        caption := 'checked';
        Checked := True;
        clicked := GetMilliseconds;
      end;
    end;
    
    procedure TForm1.InitializeObject;
    begin
      inherited;
      {$I 'Form1:impl'}
    end;
     
    procedure TForm1.Resize;
    begin
      inherited;
    end;
     
    initialization
      Forms.RegisterForm({$I %FILE%}, TForm1);
    end.

    tooquick.jpg

  7. We have made a class of button derived from TW3Button. We find that the onclick events don't work quickly on android or in responsive mode on chrome.

     

    I have attached the project. http://numberworksnwords.com/cloud/temp/button/TNWToggleButtonTest.zip

    Or you can open in browser http://numberworksnwords.com/cloud/temp/button/index.html

    On desktop or iOS a simple touch will toggle the button - a shadow will appear.

    On android browsers or when chrome is set to "responsive: you need to "click" and hold for a second or more before the button toggles.

    2017-11-22_10-34-28.gif

     

     

     

     

  8. // on click only works when not button.down
    
    
    procedure TForm1.W3Button1Click(Sender: TObject);
    begin
      writeln('entered W3Button1Click');
      tw3button(sender).down := not tw3button(sender).down;
    
      writeln(tw3button(sender).down);
    end;
    
    
    procedure TForm1.InitializeForm;
    begin
      inherited;
      // this is a good place to initialize components
    
     // visually button responds when down but even don't fire
      w3button1.PointerEventsWhileDown := true;
    end;

    2017-11-22_09-57-07.gif

    You can see button is set to down. You can see button respond to mouse but the click event does not fire.

×
×
  • Create New...