[Pas2js] Nyx framework

mister highball mr.highball at hotmail.com
Sat Oct 10 23:27:52 CEST 2020


> Thank you very much for yours sample code. If I understand it right. When i
> would want to use this framework to get text from some inputboxes, it is
> also necessary to use some event procedure. And function gettext may be
> return text from inputbox value.

You wouldn't necessarily have to use events, that is just one way. You could loop through a container's Elements collection and get the text from there, but I've updated my demo to include a debug text box which shows how you can get all of the text at once when any of the inputs change.

I've also added 3 methods showing one way to capture this text,
    (*
      this method will take TStrings (TStringList or other) and fill
      it up with "question" and "answer". The "question" will be stored
      in the "name" and the "answer" will be stored as a value
    *)
    procedure AllInputTextToStrings(const AContent : TStrings);

    (*
      this method will return a single string with the question following
      by an answer. an optional question separator string can be used
      but will default to separate with a hyphen
    *)
    function AllInputTextToString(const AQuestionSeparator  : String = '-') : String;

    (*
      returns all of the inputs content without including the question as
      a single string
    *)
    function AllInputContentOnlyToString : String;

In the "BuildUI" method, I've hooked up observation methods for when the inputs' text changes (this line here)

.ForEach(@AddTextChangeObserverToInputs);

The AddTextChangeObserverToInputs shows how one could attach a handler to respond when a user makes a change (this will trigger on every key up). In my demo the observer will just set the debug text to all the questions and the current answer, but you can attach as many different observers to property changes as you would like.

When doing this demo I had to also fix some bugs found, so just re-pull the repo and you'll have working code.

Again, this demo is found here
https://github.com/mr-highball/nyx/tree/master/demos/browser/input-labels

Hope this helps, and if you need to reach out via personal email feel free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201010/11465618/attachment-0001.htm>


More information about the Pas2js mailing list