UI definition discussion. Event handlers

Виталий Фадеев vital.fadeev at gmail.com
Mon May 10 03:29:03 UTC 2021


On Monday, 10 May 2021 at 03:22:15 UTC, Виталий Фадеев wrote:
> I want discuss with you next idea:
Same post formatted.

I want discuss with you next idea:

__This is UI definition:__

```
style
   stage
     border: 3px solid #003
     width:  100px
     height: 100px

     on: WM_LBUTTONDOWN
       {
         toggleClass( "selected" );
       }

   selected
     border: 1px solid #0C0

body
   e stage
```

Here 2 sections: style, body.
Section "style" contains classes.
Section "body" contains tree of the elements.

classes like a CSS.
tree like a HTML DOM.



__This is event handler:__
```
     on: WM_LBUTTONDOWN
       {
         addClass( "selected" );
       }
```

( When element got event WM_LBUTTONDOWN, then executed DLang 
block. )

I want discuss, next
```
{
     addClass( "selected" );
}
```

It is a long code. I want simplify it in to short form.

__How you think,__
__what is the best, readable, short, beauty form of the next 
expressions ?__
```
addClass( "selected" );
delClass( "selected" );
hasClass( "selected" );
toggleClass( "selected" );
```



PS.
I think:
```
+selected // addClass( "selected" );
-selected // delClass( "selected" );
?selected // hasClass( "selected" );
~selected // toggleClass( "selected" );
```

And events will looks like this:
```
     on: WM_LBUTTONDOWN
         +selected
     on: WM_KEYDOWN VK_SPACE
         +selected
```


More information about the Digitalmars-d mailing list