Jump to content

Czar

Members
  • Content Count

    445
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by Czar

  1. I am trying to figure out how to screen a user's typed responses and ignore characters that I don't want them to input.

     

    For example in Delphi I might do something like... 


    Procedure TNWEditPowerField.KeyPress(key : Char);
    const Numeric = ['1','2','3','4','5','6','7','8','9','0'];
    begin
      if (ord(key) < 32) or (ord(key) > 127) then exit;
      if  not (key in Numeric) and (key <> '-') and (key <> '.') then exit;
    ...

     

    But I cannot see how I would do something similar in SMS - the key strokes are all constants - any suggestions?

  2. I want an editbox that only allows entering of numbers. To do this I set inputtype to itNumber.

     

    This works but I get annoying spinners added to teh editbox so I put the following into the CSS

    input[type=number]::-webkit-inner-spin-button,
    input[type=number]::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    All good so far expect that MaxLength is now completely ignored. No matter I thought I would set MaxValue instead. e.g., set it 9999

    However, both MaxLength and MaxValue are ignored and the user can type in whatever ever number with as many characters as they like.

    Could this be remedied please?

  3. There is only a single demo using SmartCL.Grid

    The demo is rather nice looking but it seems you cannot edit the cells.

    Are there any plans for making a grid or a demo that behaves more like excel? i.e, you can select rows, cells, edit the contents etc

    I know that grid components are a massive undertaking but they are quite essential to many business applications.

     

     

     

  4. Obviously in Delphi when you create objects you need to free them.

    e.g.,

      var ButtonInstance := tNWButton.create(50, 50, 'test');
      FButtons.add(ButtonInstance);

    In Delphi I would free the objects in the form.onclose;


      while FButtons.Count>0 do
        begin
          FButtons[0].free;
          FButtons.Delete(0);
         end;

    My question, is that a requirement in SMS? What are the consequences of not freeing objects in the case of a webpage? 

     

  5. This bug is still present and a bit irritating.

    Here is the code

     

    var FeedbackInst:= tw3image.create(self);
         FeedbackInst.loadfromurl('res/ballGreen.png');
         FeedbackInst.setbounds(10,15,30,30);
         FeedbackInst.fxMoveBy(30,0, 0.5);

    I have tried it with PNGs and JPGs. Also if you leave out SetBound it will continue to do it. Much older version of SMS did not have this bug but I first noticed in 2.9.9.79

    I am hoping the devs can take a look.

    BallsMovement.rar

    2018-07-22_15-47-07.gif

  6. Thanks @lynkfs, I have it working - this is the current code that I am using and it works. There might be some redundant code in there.

     

    In Main Form

    Main Form
    
    procedure TForm1.InitializeForm;
    begin
      inherited;
      // Set teh iframe to the html page you want to communicate with
       w3IframeInfoBar.src := 'http://192.168.1.4:8092/index.html';
    end;
    
    Send a message
    
    procedure TForm1.SendWelldone;
    begin
       if assigned(w3IframeInfoBar.MessagePort) then
        begin
         writeln('Sent welldone to infobar');
         w3IframeInfoBar.handle.contentWindow.postMessage('welldone','*');
        end
         else
        writeln("No message-port has been assigned error");
    end;

     

    In the receiving program I did this

    
    procedure TForm1.InitializeForm;
    begin
      SetupSubscriber;
    end;
    
    procedure TForm1.SetupSubscriber;
    begin
      BrowserAPI.WindowObject.addEventListener('message', procedure (Event: JEvent)
      var
        LMsg: JMessageEvent;
      begin
        LMsg := JMessageEvent(event);
    
        if (string(LMsg.data).contains('msg=')) or (string(LMsg.data).contains('message=')) then
          begin
           var s : string;
           s := LMsg.data;
           delete(s,1,4);
           // DoMessage(s);
          end
          else
        if LMsg.data = 'welldone' then
          begin
            DoGreenFeedbackBalls; // put a green ball on the screen and move all feedback balls along
          end
           else
        if LMsg.data = 'sorry' then
           begin
             DoBlackFeedbackBalls;
          end
           else
        if LMsg.data = 'finished' then
           begin
             // write away results etc
              IsFinished := true;
              lblMessage.handle.style["color"] := "#008000";
              lblMessage.Caption := 'You have finished';
              TW3Dispatch.Execute( procedure () begin TaskbarFinished(true); end, 1800);
          end;
        BrowserAPI.windowobject.removeEventListener('message', @HandleWelcomeMessage); // <------------ is this required?
       end);
    end;

     

     

  7. ok, I am feeling a bit dumb. But the sender program has the iframe and it loads the infobar html page into it. The actual infobar code doesn't know it is in an iframe. So I am confused because it feels like the event listener is not inside the actual infobar code.

    Sorry if I come across a bit slow :)

  8. I am trying to understand how this works.

    Is this code only placed in the mainform?  How does the form in the iframe listen?

     

    In the mainform I do the following

    w3IframeInfoBar.src := 'http://numberworks.com/cloud/infobarnew/index.html';

    and when I send a message I assume it is
         w3IframeInfoBar.handle.contentWindow.postMessage('welldone','*');

     

    But I am confused what how I set up a listener in the other html file (the one in the iframe)

     

     

  9. In our maths tuition software we have a mainform that includes an iframe. The maths main form exercise that messages the infobar about the students actions.

    The infobar along the bottom is in an iframe that is separate from the exercise. The huge benefit is that we can have hundreds of exercises and only one infobar to change. The two parts talk using messaging. Get an answer right mainform sends the infobar a "welldone" message and a green ball appears.

     

    The latest update has changed the message system and while the code compiles it no longer works.

    I have tried to get a new system working but to be honest I am getting horribly stuck. I am hoping someone can help me out.

    I am looking for an example (using latest RTL) where one html file sends message to another html file. Simple string is all that is required.

    messaging.jpg

  10. I have since updated my CEF4 code with the latest version. No change.

    I have made a very simply VCL sms program with an image loading a png. And it fails when opening via CEF4 browser. If I copy the index.html into a webserver then the browser will show images but not when it is a local file.

    I have been using this browser for a number of years to display SMS index.html files so I would keen to have it resolved the change is the new SMS version.

  11. The behaviour for this

     

    BackImg.LoadFromURL('res/back1366.png');

     

    has changed since the last update. It works fine in browsers (internal and external) but it no longer works in my app that uses chromium (CEF4). 

    At the moment if I compile in older version - all good - recompile in newer version and the images don't load if I use my delphi based chromium browser.

    Any suggestions about where to start looking for a solution? I am using the browser app for all of my SMS based software so this represents a significant problem for me.

     

×
×
  • Create New...