Welcome,
Guest
. Please
login
or
register
.
April 22, 2026, 08:42:49 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIButton.OnClick() error handling
« previous
next »
Print
Pages: [
1
]
Author
Topic: UIButton.OnClick() error handling (Read 5265 times)
mulova
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
UIButton.OnClick() error handling
«
on:
August 18, 2014, 09:42:35 PM »
All UIButtons are not responsive after the UIButton.onClick EventDelegates throws error.
It's because UIButton.current is not null afterward.
protected
virtual
void
OnClick
(
)
{
if
(
current
==
null
&&
isEnabled
)
{
current
=
this
;
try
{
EventDelegate
.
Execute
(
onClick
)
;
}
finally
{
current
=
null
;
}
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIButton.OnClick() error handling
«
Reply #1 on:
August 19, 2014, 10:59:44 AM »
Ideally the try/catch block should be inside EventDelegate.Execute to cover all cases. Still, you shouldn't have exceptions in your code to begin with, they can lead to all kinds of problems.
Logged
mulova
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 14
Re: UIButton.OnClick() error handling
«
Reply #2 on:
August 21, 2014, 08:24:23 PM »
You are absolutely right. But there may be exceptional cases hardly found.
And Programmers like me always make mistakes.
If all the buttons doesn't work in real situation it would be like hell.
I think exception handling makes NGUI robust.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIButton.OnClick() error handling
«
Reply #3 on:
August 22, 2014, 03:54:50 AM »
Yup, which is why I already added the try/catch block to the EventDelegate.Execute back when I wrote that last reply.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIButton.OnClick() error handling