Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2020-10

html widgets layout question

13 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mgr. Janusz Chmiel

Dear specialists,
Is it possible to use some words to specify The page layout which is being created by using HTMlwidgets unit? Allingment, ETC? Because my screen reader inform Me about Editable fields that it is in one line. In one big long line, that every input box is not on A separate line. Is it possible to overcome this? Or is it only screen reader issue, because input boxes are not stored at A long big line by default? I mean TTextInputWidget object.
For example, when i create 35 input boxes with various labels, TTextInputWidget objects, screen reader inform Me, that all those object are stored not every input box on A separate line. But several inputboxes on A line.
My goal is to have every input box on A separate line. If is it technically possible.
Or is it not possible when using Htmlwidgets unit?

Thank you very much for yours example.

Reply by email

Michael Van Canneyt
to Mgr. Janusz Chmiel
Mgr. Janusz Chmiel wrote 15 lines
Dear specialists, Is it possible to use some words to specify The page layout which is being created by using HTMlwidgets unit? Allingment, ETC? Because my screen reader inform Me about Editable fields that it is in one line. In one big long line, that every input box is not on A separate line. Is it possible to overcome this? Or is it only screen reader issue, because input boxes are not stored at A long big line by default? I mean TTextInputWidget object. For example, when i create 35 input boxes with various labels, TTextInputWidget objects, screen reader inform Me, that all those object are stored not every input box on A separate line. But several inputboxes on A line. My goal is to have every input box on A separate line. If is it technically possible. Or is it not possible when using Htmlwidgets unit?

It is possible, but all layout must be handled using CSS or styles.

It is a design decision not to include any explicit position/size/layout properties: in HTML, best practice is to do this through CSS classes/styles.

The TWebWidgetClass has a styles collection, in which you can add CSS properties:

MyWidget.Styles.Add('min-height','12px');
MyWidget.Styles.Add('min-width','24em');
MyWidget.Styles.Add('max-height','24px');

etc. These styles will be applied to the HTML element when rendering the widget.

But personally, I use Bootstrap CSS to handle this: it gives good defaults for all elements.

All you need to do is set the appropriate class names in the 'Classes' property:

MyWidget.Classes:='btn btn-primary'

The bootstrapwidgets unit contains some specialized buttons and other controls: TRowWidget, TColWidget etc. The demobootstrap unit in the demo uses those to produce an acceptable layout.

Michael.

Reply by email

mister highball

This may or may not be helpful to you, but my framework Nyx has relative, fixed, and proportional layouts built in. Basic elements like text, buttons, checkbox, and multi line input are done (for the browser). The relative layout would let you specify an anchor to use (other element) and specify how far from this anchor and what what alignment (left, center, right). Still a lot to do since it's a work in progress but maybe you'll find some use since all UI is meant to be defined in code.

I would much rather point you to actual documentation or more complete examples but I don't have them at this point. Instead here are a few independant examples showing how to
1. Create a ui
2. Create a container to hold elements
3. Add the container and elements to ui with optional handlers for observable events
4. Render to the screen

* how to add a click handler to button - https://github.com/mr-highball/nyx/blob/340265a03bcefa5dbaf19fdbd8f342d607424aa7/test/nyx_browser_test.lpr#L377

* how to display an inout element - https://github.com/mr-highball/nyx/blob/340265a03bcefa5dbaf19fdbd8f342d607424aa7/test/nyx_browser_test.lpr#L396

* how to add a checkbox - https://github.com/mr-highball/nyx/blob/340265a03bcefa5dbaf19fdbd8f342d607424aa7/test/nyx_browser_test.lpr#L416

* how to multi line input with handler for text change - https://github.com/mr-highball/nyx/blob/340265a03bcefa5dbaf19fdbd8f342d607424aa7/test/nyx_browser_test.lpr#L434

* fairly complete to-do list (once a listbox element is added to nyx then a to-do list will be a lot simpler but this shows how to add a bunch or elements together for something) - https://github.com/mr-highball/nyx/blob/master/demos/browser/todo-list/todo_list.lpr

Hopefully someone else may also be able to provide some more insight into accomplishing this the standard way too using just htmlwidgets unit.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201002/f6b0f234/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to mister highball

Dear Mr highball,
Because I do not see at all, every Pas2js compatible unit, which is capable to create GUI on WEB page without need to specify object position values is very welcomed for all visually impaired developers. Thank you for yours tip and I will try The unit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201002/7e1fd916/attachment.htm>

Reply by email

heliosroots
to Michael Van Canneyt: It is possible, but all layout must be handled using CSS or styles. It is a design…

There should be a more simplified way of handling this at TcustomWidget .... example:

Widget.Classes := Widget.AddClasses('MyClass1 MayClass2'');
Widget.Classes := Widget.RemoveClasses('MyClass1 MayClass2'');

it would be simpler just ...

Widget.AddClasses('MyClass1 MayClass2'');
Widget.RemoveClasses('MyClass1 MayClass2'');

Reply by email

heliosroots
to Mgr. Janusz Chmiel: Because I do not see at all, every Pas2js compatible unit, which is capable to create GUI…

Using fluent interfaces seems much simpler to write ... but it doesn't seem like the direction WebWidget wants to reach .... I imagine that the author wants to make some scheme to integrate with an ide and have some RAD scheme ....

Today almost all webcomponents use the Grids or Flexbox scheme ... so almost no anchoring scheme is used ...

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote
Using fluent interfaces seems much simpler to write ... but it doesn't seem like the direction WebWidget wants to reach ....

This can be easily added with a TUIBuilder class which provides a fluent interface.

I don't want to force 'fluent' style. It can easily be added for those that prefer such a style.

I imagine that the author wants to make some scheme to integrate with an ide and have some RAD scheme ....

Correct.

Today almost all webcomponents use the Grids or Flexbox scheme ... so almost no anchoring scheme is used ...

Yes, that is exactly why I don't provide layouting properties. All must be done in style/CSS.

The plan is to integrate the browser with the lazarus IDE and have a RAD way of building pages. But the components can equally well be used with a 'fluent' UI builder class.

Michael.

Reply by email

Michael Van Canneyt
to heliosroots: There should be a more simplified way of handling this at TcustomWidget .... example:…
heliosroots wrote 11 lines
There should be a more simplified way of handling this at TcustomWidget .... example: Widget.Classes := Widget.AddClasses('MyClass1 MayClass2''); Widget.Classes := Widget.RemoveClasses('MyClass1 MayClass2''); it would be simpler just ... Widget.AddClasses('MyClass1 MayClass2''); Widget.RemoveClasses('MyClass1 MayClass2'');

Indeed. I will change the implementation.

Michael.

Reply by email

Michael Van Canneyt
to heliosroots
heliosroots wrote
How to change the attribute of the "element" in the Widget layer? example the attribute "aria" would have a direct support for the visually impaired

Locally I already have a 'ApplyAttribute' call.
(after mr. Chmiel asked for Aria support I added that) but I didn't commit this yet.

Michael.

Reply by email

mister highball

Under the hood for all nyx browser elements css is used for placement but the choice to provide some srandard mechanisms versus using straight css is that nyx is a UI framework that is meant to be a simple interface for web development AND desktop development. Ie. A nyx button when compiled for desktop will use a standard lcl button but for browser will use a standard web button element. Because of this the interface for controlling sizing and positioning needs to be simple to work for both targets.

I like fluent interfaces which is why I incorporated that throughout, however it's not a required thing to use it that way.

I also like being able to see all UI code changes in git diffs clearly vs an ide managed solution to better understand what has been done from commit to commit.

Ultimately, just another option to use (and a fun side project for me) -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201002/a7e54c05/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to Mgr. Janusz Chmiel: Thank you very much for yours answer. As I see, The best will be to stay to use…

I have found out The brilant solution. NVDA screen reader which I Am using support special mode. Where every WEB page GUi element can be placed on A separate virtual line. By other word, mode which ignore original WEB page layout. So I can perfectly use HTMLwidgets.
I will have a intensive Pascal week end to finally deeply understand The structure of Pascal sources which uses HTMlwidget unit. Thanks to NVDA default mode which represent The WEB page original layout I can know how WEB page really looks for sighted users. And to have my life more simple, I can switch to The disable display WEB page like on A screen mode. Thank all of you for yours patience.

Reply by email