Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. lynkfs

    Treeview

    or use the built-in TreeWalker
  3. lynkfs

    Treeview

    There is a treeview component in the 'native rtl' (demo, docum) See 'JTreeView' under 'Components' in the demo usage: var TreeView1 := JW3TreeView.Create(self); TreeView1.SetBounds(0, 0, 250, 200); TreeView1.Subject := 'Job roles'; TreeView1.Add('ceo','','chief executive officer'); //root TreeView1.Add('cto', 'ceo','chief technology officer'); TreeView1.Add('dev1', 'cto','developer 1'); TreeView1.Add('dev2', 'cto','developer 2'); TreeView1.Add('dev3', 'cto','developer 3'); TreeView1.Add('assistent', 'dev2','assistant developer 2'); TreeView1.Add('cfo', 'ceo','chief financial officer'); TreeView1.Add('accountant', 'cfo','bean counter'); TreeView1.Add('cmo', 'ceo','chief marketing officer'); component code unit JTreeView; interface uses JElement, JListBox, JPanel; type JW3TreeNode = class public Node, ParentNode, NodeDescription : String; Level : Integer; Children : Array of JW3TreeNode; Expanded: Boolean; Showing: Boolean; end; JW3TreeView = class(TElement) private ListBox: JW3ListBox; Title : JW3Panel; Function FindNode(ThisNode: string):JW3TreeNode; Procedure HideAllChildren(node: JW3TreeNode); Procedure Order(node: JW3TreeNode); Node : JW3TreeNode; Root : JW3TreeNode; public constructor Create(parent: TElement); virtual; Procedure Add(NewNode, ParentNode, NodeDescription: String); Procedure ShowTree; Subject: String := 'TreeView...'; end; implementation uses Globals; { JW3TreeView } constructor JW3TreeView.Create(parent: TElement); begin inherited Create('div', parent); setProperty('background-color', 'white'); Title := JW3Panel.Create(self); Title.SetProperty('background-color','#699BCE'); Title.SetProperty('color','white'); Title.SetProperty('border','1px solid white'); ListBox := JW3ListBox.Create(self); ListBox.Top := 25; //self.Observe; self.OnReadyExecute := procedure(sender: TObject) begin Title.SetBounds(0,0,width-2,22); Title.handle.value := Subject; Title.SetProperty('font-size', '0.95em'); Title.Text := Subject; ListBox.Width := self.Width; ListBox.Height := self.Height - 25; ShowTree; end; end; Procedure JW3TreeView.Add(NewNode, ParentNode, NodeDescription: string); begin // Node := JW3TreeNode.Create; Node.Node := NewNode; Node.ParentNode := ParentNode; Node.NodeDescription := NodeDescription; Node.Expanded := false; Node.Showing := false; If ParentNode = '' then begin Root := Node; Node.Level := 1; //Node.Expanded := true; //only when initially displaying all levels 2 Node.Showing := True; end; var Parent := JW3TreeNode.Create; Parent := FindNode(ParentNode); If assigned(Parent) then begin var temp := JW3TreeNode.Create; // eliminate unwanted double ups Temp := FindNode(NewNode); If (not assigned(temp)) or (temp.ParentNode <> parent.node) then begin Parent.Children.push(Node); Node.Level := Parent.Level + 1; //If node.level = 2 then node.Showing := true; //see line 82 end; end; end; Function JW3TreeView.FindNode(ThisNode:string):JW3TreeNode; begin var queue: Array of JW3TreeNode = [Root]; while (queue.length > 0) do begin var node := queue[0]; queue.delete(0); if node.Node = ThisNode then result := node; for var i := 0 to node.Children.length - 1 do begin queue.push(node.Children[i]); end; end; end; Procedure JW3TreeView.HideAllChildren(node: JW3TreeNode); begin Node.Showing := false; Node.Expanded := false; for var i := 0 to node.Children.length -1 do begin HideAllChildren(node.Children[i]); end; end; Procedure JW3TreeView.ShowTree; begin ListBox.Clear; Order(Root); end; Procedure JW3TreeView.Order(node: JW3TreeNode); begin if Node.Showing then begin var Item := JW3Panel.Create(Self); Item.SetAttribute('type','text'); Item.setProperty('background-color', 'whitesmoke'); Item.SetProperty('font-size', '0.85em'); Item.Height := 21; var prefix : string := ''; If node.children.count > 0 then prefix := '▸ ' //triangle right else prefix := ' ▫ '; //white square If node.children.count > 0 then If node.Children[0].Showing then prefix := '▾ '; //triangle down var s: string := ''; For var i := 1 to node.Level do begin S := S + ' '; end; S := S + prefix; Item.SetinnerHTML(S + node.NodeDescription); Item.tag := node.NodeDescription; ListBox.Add(Item); Item.OnClick := procedure(Sender:TObject) begin Subject := (Sender as TElement).tag; Title.Text := Subject; node.expanded := not node.expanded; For var j := 0 to Node.Children.Count -1 do Node.Children[j].Showing := Node.Expanded; If Node.Expanded = false then begin HideAllChildren(Node); Node.Showing := true; end; ShowTree; end; Item.handle.ondblclick := procedure begin window.postMessage([self.handle.id,'dblclick',subject],'*'); //= title.handle.value end; end; for var i := 0 to node.Children.length -1 do begin Order(node.Children[i]); end; end; end. // The same guts, in regular RTL code format, is used here (https://www.lynkfs.com/Experiments/Menu/Copperhead.MenuNodes.pas) and walking the tree Procedure Traverse(node: TCHMenuNode); begin writeln(node.NodeDescription) for var i := 0 to node.Children.length -1 do begin Traverse(node.Children[i]); end; end; Traverse(MenuNodes.Root);
  4. Yesterday
  5. Christian

    Treeview

    Hi, i'm currently working on a media project which is caused by its nature partially browser based. 95% of it are made in lazarus and 5% (probably less) is running in a browser. Since i am not quite familiar with javascript it takes longer to achieve everything using js, so my second attempt is to use sms instead. The application itself is a analyzer for ATSC 3 and it streams the tv signal as DASH transmission via an embedded web server. It also offers tuner related informations and statistics in json format. What i try to achieve is to load the json response from the server and to assemble a tree view with the data i received. The idea is to have the same tree structure like in the original server application). Does somebody have a suggestion how to create such a tree view display? I honestly did not thought that it is easier to play a video back, than building a tree with data Christian OPERATING MODE "2" FREQUENCY (HZ) "599000000" BANDWIDTH (HZ) "6000000" INTERMEDIATE FREQUENCY (HZ) "6000000" RSSI (dBm) "-59" MASTER LOCK "1" SNR (dB * 100) "1500" SIGNAL QUALITY (%) "30" BOOTSTRAP DONE "1" BOOTSTRAP EASINFO "0" BOOTSTRAP MAJOR "0" BOOTSTRAP MINOR "0" BOOTSTRAP PREAMBLE STRUCTURE "5" BOOTSTRAP BSR COEFFICIENT "2" LLS VALID BITMASK "1" PLP VALID BITMASK "1" L1B LOCK "1" L1D LOCK "1" BASEBAND FRAMES "66832" BASEBAND FRAME RF ERRORS "0" BASEBAND FRAME CC ERRORS "1" BASEBAND FRAME UNCORRECTED RF ERRORS "96" BER "0" OFFSET (HZ) "24" PACKET ERROR "0" L1B_FRAME_LENGTH_MODE "1" L1B_NUM_SUBFRAMES "1" L1B_PREAMBLE_NUM_SYMBOLS "2" L1B_L1_DETAIL_FEC_TYPE "1" L1B_FIRST_SUB_FFT_SIZE "0" L1B_FIRST_SUB_NUM_OFDM_SYMBOLS "71" L1B_FIRST_SUB_REDUCED_CARRIERS "0" L1B_FIRST_SUB_SCATTERED_PILOT_PATTERN "2" L1B_FIRST_SUB_SCATTERED_PILOT_BOOST "0" L1B_FIRST_SUB_SBS_FIRST "1" L1B_FIRST_SUB_SBS_LAST "1" REQUESTED PLP#0 "0" L1D_GUARD_INTERVAL (PLP#0) "0" L1D_PLP_MOD (PLP#0) "0" L1D_PLP_COD (PLP#0) "0" L1D_FREQUENCY_INTERLEAVER (PLP#0) "0" L1D_PLP_TI_MODE (PLP#0) "0" PLP0_LAYER_TYPE "0" PLP1_LAYER_TYPE "0" PLP2_LAYER_TYPE "0" PLP3_LAYER_TYPE "0"
  6. Last week
  7. lynkfs

    Node.js API in a Visual Components Project

    You're pushing the boundaries here and probably too far if you want to write directly from a client. If you only need to read a file you can do that in a couple of ways, see this post Otherwise also have a look at SmartCL.Require.pas, this article, this post and this post and even https://nwjs.io/ to see if that helps in any way. Keep us posted
  8. jarto

    Node.js API in a Visual Components Project

    I don't think you can use NodeJS api in a Visual Components Project.
  9. Hello, I want to write an app in SMS an convert it to a executable with Nativefier. For this I created a Visual Components Project. Now I want to read a file form the filesystem. I tried it with NodeFsAPI.writeFileSync, but this throws an exception "require is not defined". It is clear that it won't work in the browser, but the behavior is the same when I created an .exe with Nativefier. Is there a way to use the NodeJS APIs this way? Thank You
  10. Earlier
  11. lynkfs

    web design system usa

    Reading up a bit on web design systems Basically web design systems are a collection of rules, components, tools etc helping developers to create a consistent look and feel for the websites or apps they are developing. This link links to the design system of the us gov. Whether or not one likes this system, it is certainly comprehensive. As an example I quite like f.i this site which conforms to these rules.
  12. jarto

    Building an application

    @IElite already posted a link to my tutorial. If the problem you have is only to get the apk to your phone, I usually just connect my phone to my laptop via a usb cable and copy the apk to a folder. Then I start the file manager app in the Android phone, go to that folder, locate the apk and install it.
  13. IElite

    Building an application

    Use PhoneGap to package your project and convert to Android If you search for PhoneGap in this forum you should find a lot of threads related to it. However, I would start with the little tutorial by @jarto
  14. DelphiNoob

    Building an application

    Hi there. I have made a few test programs on sms and would like to see how it turns out on my android phone however, I have been struggling to get an apk of some sort onto my phone to test the program. Please, if you know how to test the program on a mobile device let me know, thank you.
  15. DavidRM

    Page Loading Issues with iPhone Browser

    That seems to have fixed it. Thanks! -David
  16. DavidRM

    Page Loading Issues with iPhone Browser

    I will try that. Thanks! -David
  17. lynkfs

    menu component

    Probably not the most inspiring topic, but just sharing a menu component I needed for some project. There are quite a few css based menu components around, but I wanted to have a pure smart one. This one has an unlimited number of submenus and is instantiated as a hamburger menu on a toolbar Hamburger := TCHMenu.Create(self); //nodes : id,parent,description,procedure Hamburger.Add('root','','Hamburger menu'); //root Hamburger.Add( 'projects','root','Projects'); Hamburger.Add( 'project0','projects','New project'); Hamburger.Add( 'project1','projects','Open project'); Hamburger.Add( 'project2','projects','Delete project'); Hamburger.Add( 'designers','root','Designer'); Hamburger.Add( 'designer0','designers','Domain info',clickproc); //<== execproc Hamburger.Add( 'designer1','designers','Data development'); ... Hamburger.Add( 'designer5','designers','Goal Metrics'); //some test cases below Hamburger.Add( 'test','project0','test3'); // test level 3 Hamburger.Add( 'designer5','designers','Goal Metrics'); //test on double entries Hamburger.Add( 'test0','root','test',procedure begin writeln('clickproc'); end); //test on no children Hamburger.Add( 'designer6','designers','extra test'); //test on out of order demo and project files on the .../Menu subdir
  18. Czar

    TryStrToInt bug

    Ran into this issue again - who is looking after the codegen?
  19. jarto

    Page Loading Issues with iPhone Browser

    Are you saving something to the local storage? If not, this could be as simple as just cache. In that case, try deleting the app.manifest -file and uncheck "Generate cache manifest" on the Linker page in Project Options.
  20. DavidRM

    Page Loading Issues with iPhone Browser

    Those details I mentioned: I have to go into settings, general, iPhone storage, scroll down to safari, select website data. Then swipe left on [the domain name] and press delete Thoughts? -David
  21. I've had some players report that their iPhone browser has a problem loading my Paintball Net UI web page (which was built with SMS). That is, they have to do some kind of "delete data" for the URL, then the page will load again. I'll provide more details from one of the users when I get it. Any ideas? Thanks. -David
  22. Thank you for looking into this (and applying a fix). Below is just some additional data in case you ever encounter some version of it again: The only way I've been able to somewhat reliably trigger it happening, is by jumping back and forth between two demo projects (not sure if it matters which ones, I've been using the Archimedes and PolyShape canvas demos) - opening via Windows Explorer - and some random combination of: closing tabs with "close all others" / "close all to the right" double clicking forms/units/project files in the project tree ctrl-clicking RTL unit names from within the editor occasionally running the project ... and then exiting the IDE by closing the window, before opening the other project But I haven't been able to make it happen truly deterministically. It takes a few cycles of the above, alternating between the two projects, with no obvious trigger. I had the thought that maybe I was opening a new project before the old one finished closing entirely, since I had been going through all the demos somewhat rapidly. But attempting to open/close them as fast as possible doesn't appear any more likely to trigger it. ¯\_(ツ)_/¯
  23. KultiVator

    Another GumRoad License Problem

    Many thanks for the fast turnaround - everything working fine with the new license code you sent via email. Best Regards, KultiVator
  24. jarto

    components lose name - little IDE bug

    Thank you. I'll add this to my work list.
  25. Good to know that we found the reason. Now I have to dig deeper and figure out, what causes the shortcuts to change. Edit: I still have not found a way to make the IDE to save a keyboard_shortcuts.xml with those two commands. They certainly are the reason for the conflict as those two shortcuts are set in SynEdit code. I'll solve this now by preventing those two from being saved to the xml-file.
  26. lynkfs

    Promises revisited

    Full kudo's to @warleyalex, he was the first one to come up with a working promise unit (see link in post) My posts are usually a personal discovery journey, so I started with the api docs and went from there. There are a couple of differences I've noticed, probably because of different source material or for other reasons. I've asked him.
  27. Components on the visual form lose their name property if they are cut and paste. I use this quite often as I will use a panel to organise related editboxes, and labels. 1. drop a label on the visual forum and call it lbl1 2. now drop a panel on the form. 3. We will cut the label and paste it inside form. select the lbl + ctrl X. And then select the panel and ctrl + v to paste the label into the form. 4 . This works fine but the label is now call w3label1 It would be nice if the component retained the name property.
  28. jorn

    Another GumRoad License Problem

    Also: use jea@ to adress me, and jt@ to adress Jarto. Noone uses ja@ around here 😉 Best thing would be to use support@. Then the whole team will be notified, and we won't loose the request. It will be kept and tracked in Zendesk.
  29. By the way, it happened again (keyboard shortcuts got corrupted). I replaced with the provided keyboard_shortcuts.zip again and it's back to normal. Somehow these two entries are getting added: <Cmd> <Command>64000</Command> <ShortCut>24658</ShortCut> <ShortCut2>0</ShortCut2> </Cmd> <Cmd> <Command>64001</Command> <ShortCut>24656</ShortCut> <ShortCut2>0</ShortCut2> </Cmd>
  1. Load more activity
×