Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by lynkfs

  1. Easiest way : procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var CalenderBox : TW3Panel := TW3Panel.Create(self); CalenderBox.SetBounds(10,10,252,266); CalenderBox.handle.id := 'CalenderBox'; var myCalendar : variant := new JObject; asm @myCalendar = new dhtmlXCalendarObject("CalenderBox"); end; myCalendar.disableDays("week", [7]); myCalendar.setDateFormat("%Y-%m-%d"); myCalendar.setHolidays("2019-03-19"); var yesterday : float := Now()-1; myCalendar.setInsensitiveRange(null, DateToStr(yesterday)); myCalenda
  2. Browsers pick up selected text in <textarea> and <p> type of html elements, not necessarily in each and every other type. Also they will not mess with existing clipboard data unless initiated by a user action (like clicking a button). Bit of a roundabout way of doing this, but this works (form with W3Label1 and W3Button1) procedure TForm1.W3Button1Click(Sender: TObject); begin var xCopy : Procedure(S:String); asm @xCopy = function copyToClipboard(text) { if (window.clipboardData && window.clipboardData.setData) { // IE specific code path to prevent
  3. Alternatively the intersection observer API might be a feasible approach as well. That would have the advantage of not burdening the scroll event with expensive code and being able to scroll variable row heights.
  4. did you set designMode to 'on' ? execCommand only works if this flag is set, something like browserapi.document.designMode := 'on'; btw, there is a new Clipboard Api, which supersedes the execCommand handling. Should be supported by now in modern browsers I think.
  5. lynkfs

    node ground zero

    I had the idea firmly rooted in my mind that Node is for server-side deployment only. This happens to be not the case, it is apparently feasible to use Node packages in the browser ! Talking about packages, the largest store of Node packages is NPM, which stores some 500,000 packages or more. (350,000 as per jan 2017) Not all of those are suitable for use in the browser, but a lot of them are. The ones which don't work client-side are the ones that require internet access, graphics or files, so this is not a work-around to be able to access databases on the client without going t
  6. Either one of two approaches come to mind : standardise rowheight by calculating all chat data lines in a conversation according to the width of the chatbox. And then set rowheight to the height of a single line (say 30px). For very large conversations you could use this approach, but probably a standard TW3ListBox will do. Otherwise make rowheight variable and calculate the height of all previous chats and determine which ones are in the visual viewport. That probably will take a specialised TW3ListBox.
  7. Got challenged the other day by trying to scroll large numbers of rows in a listbox. Browsers are very good at scrolling, but when row numbers become large and the scroll context becomes complex, scroll behaviour deteriorates. A simple un-optimised scrolling div is, rule of thumb, able to scroll comfortably up to a couple of hundred rows. Depending on browser and complexity. In the native framework I tweaked that a bit by setting all rows outside the visible viewport to 'display:none'. That extends comfortable scrolling somewhat, say to numbers in the low thousands. A bett
  8. The other native library referenced in this post was NW.js, previously Node-WebKit From your description that may be what you're after ? There are some other links on this forum node-webkit https://forums.smartmobilestudio.com/topic/4577-drag-and-drop-a-local-file/?tab=comments#comment-22735 nw.js @Czar https://forums.smartmobilestudio.com/topic/4048-nwjs-previously-known-as-“node-webkit/?tab=comments#comment-17309
  9. I like it I actually also like your 'ugly workaround', pretty clever
  10. A while ago I posted some ideas and a demo on the subject of 'nocode' or 'locode' development. The idea was to do a domain modelling exercise, and extract or generate an application from that with no or minimal coding required. The demo put a couple of the proposed models through its paces. After that post I put the subject back in the incubator for a bit. Sort of recently I realised that having an rtl with visual components and an ide with a form painter is a good thing to have, but only covers part of what is necessary if we need to cover process logic, or business rules, without h
  11. Back to basics : https://www.kirupa.com/html5/press_and_hold.htm Works on desktop and Android, didn't check iOS You could implement this using the js as is, or convert it (eliminate the asm blocks), or use the available units in the rtl (smartCL.eventmanager, smartCL.events, system.events and system.time)
  12. Something we all knew for a long time https://www.zdnet.com/article/microsoft-security-chief-ie-is-not-a-browser-so-stop-using-it-as-your-default/ a good thing microsoft has ditched Edge as well (hopefully Safari will solve their compatibility issues soon)
  13. Example 2 : see below (first post in that thread) for some function call examples Example 1 : depends on what attribute. In your example you want to manipulate the visibility property of a button. These types of properties usually are mapped on a property or attribute of the underlying DOM-element. In this case you could use the style element visibility : W3Button1.handle.style.visibility := 'hidden' / 'visible'. 'handle' is the doorway between object pascal on the left hand side and the dom on the right hand side. No need for an asm block here. you can go the oth
  14. you can access the iframes dom through its contentWindow or contentDocument property something like yourIFrameHTMLElement.handle.contentDocument.body (or ...handle.contentWindow.document.body) (with scripting you might run into same-origin policy concerns)
  15. Post rewritten. If using the html <form> element, as below, works for a DMVC server, then it will work for other servers like php, node as well. <form action="/file" method="post" enctype="multipart/form-data"> <input type="file" name="fupload"> <input type="submit"> </form> So the best bet would be to follow this same mechanism in Smart. The questions are then A: since there is no component in Smart which encapsulates the <form> element, how can we get one, or B: would it be possible to circumvent this <form> element comple
  16. I had a look at the DelphiMVCFramework files-upload demo. The upload page, see below, lets the user select a file and submits a form with the selected file to the server. <html> <body> <h2>DMVCFramework - FileUpload DEMO</h2> <form action="/file" method="post" enctype="multipart/form-data"> <input type="file" name="fupload"> <input type="submit"> </form> </body> </html> To emulate this in Smart, the <input type="file ... line will be taken care of by an edit box with type =itFile. You will have to set the name attribute as w
  17. I'm not up to scratch on node myself, but what I understand is that when the node http-server receives a (post or get) request from a client, the body of the request is read by the server in chunks. Every chunk-read triggers an ondata event, and usually it is there where these chunks need to be concatenated until the onend event happens (end of read of request body). There is an example here
  18. yep, express has routing built in If you're not using express, then its a matter of parsing the url yourself //add unit NodeJS.url //code based on simplehttpserver in featured demos procedure TServer.HandleRequest(Sender: TObject; const Request: TNJHttpRequest; const Response: TNJHttpResponse); var content: String; begin //Example on how to read content data (for example data sent using POST. //TNJHttpRequest itself is actually a readable stream, which can be read //in many ways. Hence, we don't automatically read it before HandleRequest is triggered. var url_parts : variant
  19. yep, this flag check looks like overkill. Is there a reason to create components default non-selectable ? Text on most if not all websites / apps is default selectable
  20. A quick test : procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components Panel1 := TW3Panel.Create(self); Panel1.SetBounds(20,20,300,300); Panel1.InnerHTML := 'text to select'; //select either one of the following lines : //Panel1.SetContentSelectionMode(tsmText); //text not selectable //Panel1.Handle.style['user-select'] := 'text'; //text not selectable //Panel1.Handle.style['-webkit-user-select'] := 'text'; //text selectable end; Executing in the IDE : the only way to select the panel text
  21. lynkfs


    update 2 : after some more testing on different platforms, the conclusion is that the window.print() method basically works on all platforms (Windows, MacOs, iOS, Android) and modern browsers (Chrome, FireFox, Safari), but only using the iFrame setup as mentioned in the prev. posts. The other methods may or may not work. The main exception is Chrome and FireFox on iOS where window.print() doesn't work at all : apparently Apple does not allow printing from Chrome in iOS due to it's policy on using alternative browser engines. These guys deserve a thumbs down, really
  22. lynkfs


    update : on Android (Chrome) only the iFrame solution works as expected : Button1 (manipulating the main window object) prints the whole page rather than just the demo html Button3 (popup window) results in a rendering error see https://www.lynkfs.com/Experiments/ReportWriter/www/reportwriter.html Going with the IFrame solution
  23. lynkfs


    Working on a component which involves printing. I've used external libraries like jsPDF, which generate printable content and they generally work fine. They also have some drawbacks though. So this component is going to rely on the browsers native 'print' command to print a complete page/form, or part thereof. 1) The print command is tied to a window object (window.print), so the possible implementations are limited to manipulating either the current window an iFrame element, which encapsulates a window object a new pop-up window (or new tab) Just to try these
  24. Looking at @IgorSavkic's argument to be able to have different form class names and unit names, I agree with him. We all have different styles and the IDE should accommodate that (so only the project manager should change unit/file names)
  • Create New...