KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Unexpected event triggers

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Jun 29, 2007 6:48 pm    Post subject: Unexpected event triggers Reply with quote

Hi, I ran into an interesting dilemma. Here is the situation: I have a set of RadioButtons in a GroupBox and a TabControl with a Button in one of the TabPages. I set the TabControl's Enabled property to zero to prevent users from making actions to the controls while an event is taking place. However, I mysteriously discovered a RadioButton event is triggered somehow when disabling the TabControl.

Here is the code. The RadioButton event returns either 1 or 2 when one of the RadioButtons are clicked (1 for the top, 2 for the bottom). Click the 'Test' Button and you'll see it triggers the RadioButton event. Please tell me what the heck is going on!

Code:

;region ScriptForm Designer

;region Constructor

Break On
$System = CreateObject("KiXforms.System")

;endregion

;region Form Creation
;Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
;When working with the ScriptForm designer this region and any changes within may be overwritten.

;~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = $System.Form()
$Form1.Size = $System.Size(510, 411)
;~~< TabControl1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabControl1 = $Form1.Controls.Add($System.TabControl())
$TabControl1.name = "TabControl1"
$TabControl1.Size = $System.Size(246, 112)
$TabControl1.TabIndex = 3
;~~< TabPage1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabPage1 = $TabControl1.Controls.Add($System.TabPage())
$TabPage1.Size = $System.Size(238, 86)
$TabPage1.Text = "TabPage1"
;~~< TabPage2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabPage2 = $TabControl1.Controls.Add($System.TabPage())
$TabPage2.Size = $System.Size(238, 86)
$TabPage2.Text = "TabPage2"
$TabControl1.Location = $System.Point(219, 32)
$TabControl1.SelectedIndex = 0
$TabControl1.SelectedTab = $TabPage1
;~~< GroupBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$GroupBox1 = $Form1.Controls.Add($System.GroupBox())
$GroupBox1.TabIndex = 2
$GroupBox1.Size = $System.Size(128, 104)
$GroupBox1.Text = "GroupBox1"
;~~< RadioButton2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$RadioButton2 = $GroupBox1.Controls.Add($System.RadioButton())
$RadioButton2.Click = 'RadioButton_Click("2")'
$RadioButton2.TabIndex = 1
$RadioButton2.Size = $System.Size(104, 24)
$RadioButton2.Text = "RadioButton2"
$RadioButton2.Location = $System.Point(6, 62)
$RadioButton2.TabStop = True
;~~< RadioButton1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$RadioButton1 = $GroupBox1.Controls.Add($System.RadioButton())
$RadioButton1.Click = 'RadioButton_Click("1")'
$RadioButton1.TabIndex = 0
$RadioButton1.Size = $System.Size(110, 28)
$RadioButton1.Text = "RadioButton1"
$RadioButton1.Location = $System.Point(6, 28)
$RadioButton1.TabStop = True
$GroupBox1.Location = $System.Point(49, 32)
$Form1.Text = "Form1"

$Button1 = $TabPage1.Controls.Add($System.Button())
$Button1.Text = "Test"
$Button1.Click = 'Button_Click()'
$Button1.Size = $System.Size(100, 50)
$Button1.Location = $System.Point(50, 10)

;endregion

;region Event Loop

$Form1.Show
While $Form1.Visible
   $=Execute($System.Application.DoEvents)
Loop

;endregion

;endregion

Function Button_Click()
   $TabControl1.Enabled = 0
EndFunction

Function RadioButton_Click($i)
   ? $i
   $TabControl1.Enabled = 1
EndFunction
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon Jul 02, 2007 12:00 pm    Post subject: Reply with quote

just a guess, but try disabling the tabstop on the radiobutton.

might be that disabling the tabcontrol moves the tab-order to the button and somehow fakes a click.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon Jul 02, 2007 2:45 pm    Post subject: Reply with quote

I set the tabstop to 0, but it still is triggering the radiobutton event. I'm at a loss here. Confused
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon Jul 02, 2007 9:10 pm    Post subject: Reply with quote

hmm...
do a simple printout of what is happening:
Code:

While $Form1.Visible
   $System.Application.DoEvents ?
   $=Execute($System.Application.DoEvents)
Loop


could lead us to something...

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Jul 02, 2007 9:13 pm    Post subject: Reply with quote

Its seems that the act of "enabling" the TabControl triggers the click event of whatever RadioButton is selected. Take out the enabling and the behavior seems good.

Why this is will have to researched.

Changed the event functions like this:

Code:

Function Button_Click()
 ?"Button_Click()"
 $TabControl1.Enabled = 0
 $TabControl1.Enabled = 1
EndFunction

Function RadioButton_Click($i)
 ?"RadioButton_Click($i)"
EndFunction
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Jul 02, 2007 9:34 pm    Post subject: Reply with quote

I tried to repro this in vs 2005 and could not. Then I realized that in my test, I wasn't writing to the console like in Kix - I was tracing to a TextBox - so I ported the code from vs2005 back to Kix and found that it behaves normal with a TextBox (a 3rd control) on the form ...

So I'm still not sure if its a kf.net or .net thing ... going to try to emulate this better in .net ...

Code:

;region ScriptForm Designer

;region Constructor

Break On
$System = CreateObject("KiXforms.System")

;endregion

;region Form Creation
;Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
;When working with the ScriptForm designer this region and any changes within may be overwritten.

;~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = $System.Form()
$Form1.Size = $System.Size(510, 411)
;~~< TabControl1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabControl1 = $Form1.Controls.Add($System.TabControl())
$TabControl1.name = "TabControl1"
$TabControl1.Size = $System.Size(246, 112)
$TabControl1.TabIndex = 3
;~~< TabPage1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabPage1 = $TabControl1.Controls.Add($System.TabPage())
$TabPage1.Size = $System.Size(238, 86)
$TabPage1.Text = "TabPage1"
;~~< TabPage2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TabPage2 = $TabControl1.Controls.Add($System.TabPage())
$TabPage2.Size = $System.Size(238, 86)
$TabPage2.Text = "TabPage2"
$TabControl1.Location = $System.Point(219, 32)
$TabControl1.SelectedIndex = 0
$TabControl1.SelectedTab = $TabPage1
;~~< GroupBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$GroupBox1 = $Form1.Controls.Add($System.GroupBox())
$GroupBox1.TabIndex = 2
$GroupBox1.Size = $System.Size(128, 104)
$GroupBox1.Text = "GroupBox1"
;~~< RadioButton2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$RadioButton2 = $GroupBox1.Controls.Add($System.RadioButton())
$RadioButton2.Click = 'RadioButton_Click("2")'
$RadioButton2.TabIndex = 1
$RadioButton2.Size = $System.Size(104, 24)
$RadioButton2.Text = "RadioButton2"
$RadioButton2.Location = $System.Point(6, 62)
$RadioButton2.TabStop = True
;~~< RadioButton1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$RadioButton1 = $GroupBox1.Controls.Add($System.RadioButton())
$RadioButton1.Click = 'RadioButton_Click("1")'
$RadioButton1.TabIndex = 0
$RadioButton1.Size = $System.Size(110, 28)
$RadioButton1.Text = "RadioButton1"
$RadioButton1.Location = $System.Point(6, 28)
$RadioButton1.TabStop = True
$GroupBox1.Location = $System.Point(49, 32)
$Form1.Text = "Form1"

$Button1 = $TabPage1.Controls.Add($System.Button())
$Button1.Text = "Test"
$Button1.Click = 'Button_Click()'
$Button1.Size = $System.Size(100, 50)
$Button1.Location = $System.Point(50, 10)

$TextBox1 = $Form1.Controls.Add($System.TextBox())
$TextBox1.MultiLine = 1
$TextBox1.Dock = $System.DockStyle_Bottom
$TextBox1.Height = 150

;endregion

;region Event Loop

$Form1.Show
While $Form1.Visible
   $=Execute($System.Application.DoEvents)
Loop

;endregion

;endregion

Function Button_Click()
 ?"Button_Click()"
 $TabControl1.Enabled = 0
 $TabControl1.Enabled = 1
EndFunction

Function RadioButton_Click($i)
 ?"RadioButton_Click($i)"
EndFunction
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Jul 02, 2007 9:39 pm    Post subject: Reply with quote

k, I reproduced this behavior perfectly in vb.net (vs 2005). So its either a bug in .net OR by design. Trying to figure-out if by design, why it would be so.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Jul 02, 2007 10:12 pm    Post subject: Reply with quote

I "reduced" the problem down to a form, a single radiobutton, and a button (enabling and disabling the button instead of the tabcontrol) - same odd behavior.
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Mon Jul 02, 2007 10:57 pm    Post subject: Reply with quote

so because disabling/enabling the tabcontrol also disables/enables the child controls, I can see how disabling/enabling the button would result in the same odd behavior.

Thanks for working on this, Shawn. I do have a workaround in the meantime (just let it be), but I hope you find a solution to this.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Jul 02, 2007 11:09 pm    Post subject: Reply with quote

I won't be able to find a solution to this...

The only thing I could do is post this problem to a .net bbs somewhere, then get a "bug or by design" response from ms and maybe a fix in some furture release of .net.

By the way - the Click event is implemented not by the RadioButton itself, but by a base class called "Control" - which is generic and common to all controls ... for the RadioButton, maybe you should give the CheckChanged event a try.
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Thu Jul 05, 2007 5:54 pm    Post subject: Reply with quote

Oooh great idea Shawn. I'll just use CheckChanged event instead.

Thanks for looking into this! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group