digitalmars.D - UI definition discussion. Event handlers
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (50/50) May 09 2021 I want discuss with you next idea:
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (64/65) May 09 2021 Same post formatted.
I want discuss with you next idea: This is UI definition: style stage width: 100px height: 100px on: WM_LBUTTONDOWN { toggleClass( "selected" ); } selected 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
May 09 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 width: 100px height: 100px on: WM_LBUTTONDOWN { toggleClass( "selected" ); } selected 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 ```
May 09 2021