Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Button needs 2 clicks



Permlink Replies: 5 - Last Post: Sep 28, 2017 12:27 PM Last Post By: Alexandre Machado
S. Mahaux

Posts: 40
Registered: 4/4/02
Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 5, 2017 10:49 AM
I have a IWForm with a search button. The OnClick event is only fired on the second click.
Why would that be?
Thanks for any suggestions.
S. Mahaux

Posts: 40
Registered: 4/4/02
Re: Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 5, 2017 11:02 AM   in response to: S. Mahaux in response to: S. Mahaux
It looks like this only happens when the app is accessed using SSL (TLSv12)
Alexandre Machado

Posts: 1,641
Registered: 8/10/13
Re: Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 6, 2017 12:34 AM   in response to: S. Mahaux in response to: S. Mahaux
S. Mahaux wrote:
I have a IWForm with a search button. The OnClick event is only fired on the second click.
Why would that be?
Thanks for any suggestions.

Hi,

which version are you using?

Are you able to track it down through browser developer tools?

If you are using Chrome, Firefox or IE, just hit F12 and go to the network tab. See if you can identify any request being sent to the browser when you click the button.
S. Mahaux

Posts: 40
Registered: 4/4/02
Re: Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 7, 2017 8:38 AM   in response to: S. Mahaux in response to: S. Mahaux
Using the Firefox's network dev tab, I can see that the button's OnClick was not being fired. However, the edit control's OnAsyncChange did. If comment out most of the code in that event, then the click event fired correctly.
So, what in the following SearchEditAsyncChange() event could prevent the SearchButtonClick()?

void __fastcall TSearchForm::SearchEditAsyncChange(TObject *Sender, TStringList *EventParams)
// Build seach value.
{
TControl* sender = dynamic_cast<TControl*>( Sender ) ;

searchValue_M = "" ;
String separator ;

for( int ctr=0; (ctr < SearchRegion->IWComponentsCount); ctr++ )
{
TComponent* iwComponent = SearchRegion->Component[ ctr ] ;

TIWEdit* edit = dynamic_cast<TIWEdit*>( iwComponent ) ;
if( edit && (edit->Tag == sender->Tag) )
{
assert( edit->Tag ) ;

searchValue_M += separator + edit->Text.Trim() ;
separator = "/" ;
}//if found matching edit
}//for
}//SearchEditAsyncChange()
Chad Hower

Posts: 478
Registered: 3/2/07
Re: Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 23, 2017 11:44 AM   in response to: S. Mahaux in response to: S. Mahaux
I didnt have time to look deeply, but JS events take a result. If you
return the wrong result it means "cancel further processing".

On 9/7/2017 11:38 AM, S. Mahaux wrote:
Using the Firefox's network dev tab, I can see that the button's OnClick was not being fired. However, the edit control's OnAsyncChange did. If comment out most of the code in that event, then the click event fired correctly.
So, what in the following SearchEditAsyncChange() event could prevent the SearchButtonClick()?

void __fastcall TSearchForm::SearchEditAsyncChange(TObject *Sender, TStringList *EventParams)
// Build seach value.
{
TControl* sender = dynamic_cast<TControl*>( Sender ) ;

searchValue_M = "" ;
String separator ;

for( int ctr=0; (ctr < SearchRegion->IWComponentsCount); ctr++ )
{
TComponent* iwComponent = SearchRegion->Component[ ctr ] ;

TIWEdit* edit = dynamic_cast<TIWEdit*>( iwComponent ) ;
if( edit && (edit->Tag == sender->Tag) )
{
assert( edit->Tag ) ;

searchValue_M += separator + edit->Text.Trim() ;
separator = "/" ;
}//if found matching edit
}//for
}//SearchEditAsyncChange()
Alexandre Machado

Posts: 1,641
Registered: 8/10/13
Re: Button needs 2 clicks
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 12:27 PM   in response to: S. Mahaux in response to: S. Mahaux
I don't have access to the whole code and generated page, so I'm guessing. If you change the edit and then try to click a button, the events will happen in this order:
- onblur (on your IWEdit, which will trigger OnAsyncChange if the content has changed)
- onclick (on your IWButton)

So, I believe that there is a timing issue there.

Are you able to recreate this in a simple test case?

S. Mahaux wrote:
Using the Firefox's network dev tab, I can see that the button's OnClick was not being fired. However, the edit control's OnAsyncChange did. If comment out most of the code in that event, then the click event fired correctly.
So, what in the following SearchEditAsyncChange() event could prevent the SearchButtonClick()?

void __fastcall TSearchForm::SearchEditAsyncChange(TObject *Sender, TStringList *EventParams)
// Build seach value.
{
TControl* sender = dynamic_cast<TControl*>( Sender ) ;

searchValue_M = "" ;
String separator ;

for( int ctr=0; (ctr < SearchRegion->IWComponentsCount); ctr++ )
{
TComponent* iwComponent = SearchRegion->Component[ ctr ] ;

TIWEdit* edit = dynamic_cast<TIWEdit*>( iwComponent ) ;
if( edit && (edit->Tag == sender->Tag) )
{
assert( edit->Tag ) ;

searchValue_M += separator + edit->Text.Trim() ;
separator = "/" ;
}//if found matching edit
}//for
}//SearchEditAsyncChange()
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02