Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 12/18/2019 in all areas

  1. 5 points
    We are proud to release Smart Mobile Studio 3.9.1. This is the first Alpha release of the upcoming Smart Mobile Studio 4.0. The biggest improvement is the new WYSIWYG Designer, which takes developing visual applications in SMS to a new level. The compiler was updated with a new version of DWS (Delphi Web Script) and the IDE uses an updated Chromium component. On top of this, there are new components and improvements to the RTL....... Please read the release notes here: https://smartmobilestudio.com/2019/12/20/smart-mobile-studio-3-9-1-released/
  2. 5 points
    Daniel Eiszele

    NodeJS Route Manager

    The attached uRouter.pas file is something I've been playing with for the last couple of days. It is basically a route manager (think ExpressJS) for Smart Mobile Studio. It isn't fully baked at this point in time and I probably won't progress it far past this point as it already meets my needs from a REST Service perspective. Feel free to use it as a base for your own efforts though. It works in both http and https environments. Just create a global var on your NodeProgram object to hold it and instantiate it after the server object is created with the following call: FRouter := TRouteManager.Create(FServer); Do not manually set the request handler as the constructor sets that up for you. To create routes, use the following syntax: FRouter.get('/', procedure (const Request: TNJHttpRequest; const Response: TNJHttpResponse; data : TRequestData; data : TRequestData) begin Response.end('You Selected the Root Directory'); end); FRouter.post('/', procedure (const Request: TNJHttpRequest; const Response: TNJHttpResponse; data : TRequestData; data : TRequestData) begin Response.end('You Selected a post request'); end); FRouter.put('/', procedure (const Request: TNJHttpRequest; const Response: TNJHttpResponse; data : TRequestData; data : TRequestData) begin Response.end('You Selected a put request'); end); FRouter.delete('/', procedure (const Request: TNJHttpRequest; const Response: TNJHttpResponse; data : TRequestData; data : TRequestData) begin Response.end('You Selected a delete request'); end); To access data when it's available, you may manually retrieve it from the request object or use one of two functions on the data / TRequestdata object as per below. data.BodyAsBuffer(procedure (_Buffer : JNodeBuffer) begin Response.End('Here is the buffer: ' + _Buffer.toString('utf8'); end); or data.BodyToFile('C:\temp\aFile.pdf',procedure(err : JError) begin if assigned(err) then begin Response.end('Something went wrong'); end else begin Response.end('File has been saved'); end end); Similarly, url parameters can be read off the TRequestdata object as follows. Response.end('You requested id: ' + data.Params.ReadString('id')); Let me know what you think uRouter.pas
  3. 5 points
    2nd Alpha release of the upcoming version 4.0 is now available. You can install it with SmartUpdate from the ALPHA-channel. If you have installed the first alpha release, you can simply run SmartUpdate in the same folder. Designer: If a component is added by just clicking, it's created at 96x32 size Prevent deletion of form IDE: Disable adding of units to uses-section when a form is opened Required units will still be added when a component is added to the form Add a message if the IDE's internal server can not start Bug fix to sorting of forum posts on the Welcome Page Small bug fix to Switch Comment
  4. 3 points
    Congrats on the new Baby and the new release!
  5. 3 points
    Huge thanks in developing this version also go to Christian Budde, who is one of the original developers of Smart Mobile Studio. Christian helped with updating the DWS and the embedded Chromium component.
  6. 2 points
    jarto

    Bugs and Features 3.1.0.88

    A fix to this will be in alpha2.
  7. 2 points
    JimKueneman

    Float 16

    It is even easier than that! function FloatToHalf(Float: Single): THalfFloat; var Src: LongWord; {$IFDEF DWSCRIPT} Sign, Exp, Mantissa: Integer; {$ELSE} Sign, Exp, Mantissa: LongInt; {$ENDIF} begin {$IFDEF DWSCRIPT} var Bytes: TByteArray; Bytes := TDataType.Float32ToBytes(Float); Src := LongWord( TDataType.BytesToInt32(Bytes)); {$ELSE} Src := PLongWord(@Float)^; {$ENDIF} and back function HalfToFloat(Half: THalfFloat): Single; var Dst, Sign, Mantissa: LongWord; {$IFDEF DWSCRIPT} Exp: Integer; {$ELSE} Exp: LongInt; {$ENDIF} begin ............ {$IFDEF DWSCRIPT} var Bytes: TByteArray; Bytes := TDataType.Int32ToBytes(Dst); Result := TDataType.BytesToFloat32(Bytes); {$ELSE} // Reinterpret LongWord as Single Result := PSingle(@Dst)^; {$ENDIF}
  8. 2 points
    Well, my wife won the release competition earlier this week, but now the Alpha is also delivered. It's available with SmartUpdate in the ALPHA-channel.
  9. 1 point
    lynkfs

    css styling

    Browsers are certainly talented as multi-language processors. They have to understand html, css, javascript, svg and lately web-assembly as a fifth language. XML and Json are format specifiers, but could be borderline categorised as languages as well. Smart elevates javascript to great heights, but sort of leaves the other ones at the periphery. Especially css. Css can be used for a) component styling including colours, fonts etc, b) visual layout of pages/forms and reacting responsively to screen size and orientation and c) interactivity in various forms. Some of this overlaps with the js domain. Smart basically uses css for a) but not for b) or c). Looking at various css frameworks out there, I would categorise these as on one end of the scale there are many UI kit frameworks where the emphasis is on components - buttons, accordions, cards etc. Sometimes as css stand-alone files, sometimes in conjunction with js. Most of these also have functionality for layout purposes, usually based on flexbox or internal grid structures. on the other end of the scale there are frameworks which forego the component focus, but instead provide a large number of elementary styling functions, which can be applied to any component. and many which occupy a space in between This post is about the open source Tailwind framework, belonging in the second category above, just to see how that would work in the Smart environment. Tailwind comes in 2 flavours : a static framework which can be accessed locally or from a cdn, and a more dynamic version. The latter can be tailored dynamically for any specific project and basically needs to be part of the build toolchain. To keep it simple I used the static version. Change the res/app.css reference to the tailwind css file (either just replace it or change the reference in the index.html file). Now any component can be made to use this styling. Because this is not more (or less) than a list of individual styling functions, the use boils down to defining what you want. Tell a story as in "give me a button with a green background, which turns to blue on hover, has rounded corners and white text and a shadow effect which makes it seem floating". In code : W3Button1.handle.className := "bg-green-500 hover:bg-blue-700 text-white rounded shadow-2xl"; The second button in the demo project (see below) has a different story (className sequence), which gives it a totally different look and feel. I kind of like this approach, it works very well with any component, thus also with the built in Smart components. It is a bit of a drag specifying these className sequences by hand, so it would be nice if this would be supported in the IDE. There are after all only a small number of categories of these elementary styling bits : backgrounds, typography, borders, spacing, sizing, svg, interactivity and effects. And a relatively limited list of functions per category (bg-green-500 means a green background, 500 is the fifth shade in the green colour scheme. So there will be a bg-green-600, a bg-blue-200 etc). Doable I think. Apart from these styling functions, Tailwind also has a number of layout functions. Smart has its own layout mechanism, however the Tailwind functions can be used as well. See the 'card' component in the demo. Demo and source
  10. 1 point
    jarto

    Nodejs https ciphers out of date

    I'll include the fix, new ciphers and new self signed certificates in the next update
  11. 1 point
    Daniel Eiszele

    Nodejs https ciphers out of date

    Right here -> https://nodejs.org/api/tls.html#tls_modifying_the_default_tls_cipher_suite
  12. 1 point
    Daniel Eiszele

    Nodejs https ciphers out of date

    Funny, I just found that bug myself. Guess I don't have to report it now
  13. 1 point
    jarto

    Nodejs https ciphers out of date

    Edit: There are two reasons for problems: Expired (and self signed) ssl certificate, which the browsers are warning about. You can bypass the warning and accept the self signed certificate. There's a bug in TNJHTTPSServer.Dispatch SmartNJ.Server.Https.pas. I fixed this very same issue in http ages ago but didn't realize that the same bug was in https as well. The correct code is below procedure TNJHTTPSServer.Dispatch(request: JServerRequest; response: JServerResponse); begin if assigned(OnRequest) then begin var LRequest := TNJHttpRequest.Create(self,request); var LResponse := TNJHttpResponse.Create(self,response); try OnRequest(self, LRequest, LResponse); except on e: exception do begin Raise ENJHttpServerError.CreateFmt ('Dispatch failed, system threw exception %s with message [%s]', [e.ClassName, e.Message]); end; end; end; end; When I use this fix and accept the self signed certificate, the demo works,
  14. 1 point
    That worked. Thank you.
  15. 1 point
    jarto

    TW3ButtonGroup?

    I have to think about it to see what would be the best solution. I also have to have a deep look at the toolbar. It's still original code.
  16. 1 point
    I still get nothing, am I still missing something? I need to capture keys at the application or form level. procedure TForm1.HandleKeyDown(eventObj: JKeyboardEvent); begin Writeln(EventObj.charCode); end; procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components Self.Handle.addEventListener('keydown', @HandleKeyDown, True); end; UPDATED Looks like I can capture using application Application.Document.Handle.addEventListener('keydown', @HandleKeyDown, True); OR TApplication = class(TW3CustomApplication) protected procedure ApplicationStarted; override; procedure HandleKeyDown(eventObj: JKeyboardEvent); end; implementation procedure TApplication.HandleKeyDown(eventObj: JKeyboardEvent); begin if EventObj.keyCode in [49,50,51,52] then Writeln(IntToStr(EventObj.keyCode)); end; procedure TApplication.ApplicationStarted; begin inherited; Document.Handle.addEventListener('keydown', @HandleKeyDown, True); end;
  17. 1 point
    I am tying to capture it on the main form, but I could do it on a panel as well But let me try your addEventListener suggestion, cause that was what i was trying to do with the W3_Bind2
  18. 1 point
    In the RTL, have a look at CreationFlags. If a control is supposed to listen to keyboard events, then CreationFlags-function is overridden and the cfKeyCapture-flag is added. It also means that the control can then receive focus. If you just want to capture keyboard events regardless of the control, you may want to use simple event listeners: Self.Handle.addEventListener('keydown', @HandleKeyDown, True); procedure TForm1.HandleKeyDown(eventObj: JKeyboardEvent); begin ... //Here you can then call eventObj.preventDefault or eventObj.stopImmediatePropagation if you handled the event and want to prevent it from going to the control itself. end;
  19. 1 point
    jarto

    Alpha Release Suggestion

    I bet I know why this happens. They probably use the same port (IDE Settings/Server/Port) If you have two installations in separate folders and different ports, there should be no problems. I have to make a nice error message for this situation.
  20. 1 point
    jarto

    Alpha Release Suggestion

    Gotta check this. Thank you. It will be certainly possible. Also notice that the ToolBar is the original one from ages ago, so there's room for improvement there. Good catch. This is probably because these underlying controls don't listen to keyboard events. This should be an easy fix. Yes. Probably a button with changeable glyph could be best, like in Delphi Thank you very much and also happy holidays!
  21. 1 point
    Awesome! Looking forward to taking it for a test run.
  22. 1 point
    JimKueneman

    What is going on.....

    Looking forward to that. I am not working on the UI for my project yet as I want to use the new version for that. I have one more issue and I think my converted Lazarus code will successfully run through my complete test suite testing a custom TCP protocol running over WebSockets with very very little required in {$IFDEF}'s.
  23. 1 point
    jarto

    What is going on.....

    Good to know. We are really close to releasing the next alpha-release. It contains a compiler with an updated DWS. Once that's out, it'll be interesting to see if it makes a difference. Even if it doesn't we'll be in a situation where we should be able to include fixes to issues like these easily.
  24. 1 point
    JimKueneman

    What is going on.....

    Ok Jarto there is a limitation in the compiler. If I do what you suggest it works just fine. It also work fines if I define that constant as a variable then load it with the default values then make the assignment. Note in the latter the compiler uses the slice function. I think that is the issue. If the assignment is with a constant array this assignment is not being compiled with the slice function: JS compiled code if NULL_NODE_ID is a variable. Self.FDestID = NULL_NODE_ID.slice(0);
  25. 1 point
    With the help of Jarto and a few here I have almost 5000 lines of a Lazarus/Delphi library that implements a mature custom TCP protocol compiling with SMS with just a few {$IFDEF DWSCRIPT}'s required so far. I have about 1000 more line to go before I can give it a full test but I do have a Websocket connected to the library and have sent messages to the library from a Lazarus program and it received and decoded them correctly. I was only working on it for a few hours on and off yesterday so I am amazed and very happy. Hopefully it will all run correctly in the end but at least the compiler thinks it should. The key websites that have helped me get handle on thing are here but so far I have not used them directly, SMS has handled everything in the compile so far but I do have a few dynamic byte array that I need to mimic which will need this information.... https://jonlennartaasenden.wordpress.com/2017/06/04/smart-pascal-memory-and-pointers/ https://jonlennartaasenden.wordpress.com/2015/03/07/system-interop-how-to-for-smart-mobile-studio/ https://www.html5rocks.com/en/tutorials/webgl/typed_arrays/ The ultimate goal is to create phone apps Jim
×