Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some problems with some events of some components
#1
Good afternoon, creating a simple Indy application working with Delphi 11.1 and IW15.2.51 I have noticed some problems with the components IWCheckBox, IWDBCheckBox, IWRadioButton and IWRadioGroup

For IWCheckBox and IWDBCheckBox
---------------------------------------

1.- The OnAsyncClick event is executed 2 times when we make a single click in the LABEL element of the component. It behaves normally when we make a single click on the INPUT element of the component.

2.- The OnAsyncEnter event does not work.

3.- The OnAsyncExit event does not work.

4.- The OnChange event behaves as an asynchronous event.

5.- The OnClick event does not change the state of the checkbox when we click on the LABEL element of the component. It behaves normally when we click on the INPUT element of the component.

For IWRadioButton
---------------------------------------------

1.- The OnAsyncChange event only works when the component is initially in UnChecked state and we click on it, it does not work if its state is changed asynchronously from another component, for example from a button, or when clicking on another IWRadioButton.

2.- The OnAsyncEnter event does not work.

3.- The OnAsyncExit event does not work.

4.- The OnClick event only works if we click on the INPUT element of the component. If we click on the LABEL element of the component, it changes its state (as if it were an asynchronous event) but the OnClick event is not executed.

For IWRadioGroup
------------------------------------------

1.-The OnAsyncChange event is only executed if we click on any of the items of the component. If we change the itemIndex from another component asynchronously, for example from a button, the index changes but the OnAsyncChange event is not triggered.

The OnClick event behaves as an asynchronous event if we click on the LABEL element of the component. It behaves normally if we click on the INPUT element of the component.

Please if someone could confirm this for an eventual correction I would be grateful.
Reply
#2
I'll have a look and let you know ASAP
Reply
#3
1- The OnAsyncChange event is working as designed/expected. HTML DOM OnChange event doesn't trigger if the property is changed via code (you can test this with a simple HTML such as:

Code:
<!DOCTYPE html>
<html>
<body>

<input id="myCheckBox" type="CHECKBOX" onchange="myChangeEvent()">

<script>
function myChangeEvent() {
  alert("onchange triggered");
}
</script>

</body>
</html>


If you open the console in Dev tools (F12) and type:

document.getElementById("myCheckBox").checked = true

you will see that the alert() message won't popup (but it will in any other case where the user directly changes the value via keyboard or mouse).

This is one of multiple security layers of the browser. The browser "knows" and treats differently what is done by direct user intervention (e.g. a mouse click) and what is done via code (setting a property of a DOM element). Our implementation follows the same rules.

2- OnClick of the IWRadioButton: In my tests it works correctly. Have in mind that IWRadioButtons only work if there are more than one with the same Group property. If you have only one RadioButton, it won't work as a CheckBox.

3- CheckBox's OnAsyncChange is indeed triggering twice. This is going to be fixed.

4- OnAsyncEnter/OnAsyncExit are not working as you would expect because they are attached to the label part of the control, not the control itself. To be honest, it's not usual to attach any code to these events for CheckBoxes and RadioButtons, but I'll add it to the TODO list as well

BTW, in all metioned controls, use always OnAsyncChange/OnChange events if you are interested in the state of the control. Never use OnAsyncClick/OnClick events, unless you really want to detect a mouse click over the control, not a state change.
Reply
#4
Thank you Alexandre.
I wanted to clarify that it is the OnAsyncClick event of the IWCheckBox that is executed twice.
Regarding problem 1 that I mention for the IWRadioButton: If I place two IWRadioButton (same group) and I click on the IWRadioButton2, the OnAsyncChange event of the IWRadioButton1 doesn't work, the same if I want to click on the IWRadioButton1, the OnAsyncChange event of the IWRadioButton2 doesn't work.
Regarding the problem 4 that I mention for IWRadioButton: The problem occurs when I want to insert code in the OnAsyncChange and OnClick events simultaneously. Thanks for your help
Reply
#5
> The problem occurs when I want to insert code in the OnAsyncChange and OnClick events simultaneously

Can you please elaborate what's your use case here?

As I mentioned in my response this is the rule of thumb regarding CheckBoxes:

- If you want to respond to state change (checked/unchecked), OnChange/OnAsyncChange are the events you must use.

- If you want to respond to mouse clicks over the control (regardless of the state), OnClick/OnAsyncClick are the events you must use

I'm curious to know what's your use case where you need to use both... (and yes, they both work)
Reply
#6
Quote:Regarding problem 1 that I mention for the IWRadioButton: If I place two IWRadioButton (same group) and I click on the IWRadioButton2, the OnAsyncChange event of the IWRadioButton1 doesn't work, the same if I want to click on the IWRadioButton1, the OnAsyncChange event of the IWRadioButton2 doesn't work.

This is correct and expected. It's the similar to the CheckBox issue. That's how browsers behave.

The DOM event only fires for the control that had a direct user action (mouse click or key pressed). Although the other radio button also changed the state (From checked to unchecked) only the unchecked -> checked state change triggers the event.

This shouldn't be an issue if you have a single event handler for all Radio buttons belonging to the same group (the recommended way to deal with this).
Reply
#7
Please update to IW 15.2.52. It contains fixes for the reported issues (OnAsyncClick fires twice, OnAsyncEnter/OnAsyncExit don't trigger)

https://www.atozed.com/2022/04/intraweb-15-2-52/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)