View previous topic :: View next topic |
Author |
Message |
Viggen KiXforms Regular

Joined: 28 Jun 2005 Posts: 40
|
Posted: Mon Nov 17, 2008 11:09 am Post subject: How do I remove .AcceptButton from a button? |
|
|
Got a small problem with .AcceptButton, or rather, removing it...
I have a small app where I have, say $Textbox1 and when someone enters it and starts typing, it sets $Form1.AcceptButton = $Button1
So far so good
When the button is clicked it stores the info in Textbox1, and then sets Focus to $Textbox2.
This box has $Textbox2.AcceptsReturn = -1
What I want, is to be able to just press enter, and have the function processing the info in Textbox2, and then setting the focus back to box2, so one can keep entering info in box2.
I have that senario set up and functioning (if I don't use AcceptButton), so how do I clear the .AcceptButton from $Form1?
/Viggen |
|
Back to top |
|
 |
Gargoyle KiXforms Aficionado


Joined: 30 Dec 2003 Posts: 366 Location: Arizona
|
Posted: Mon Nov 17, 2008 1:02 pm Post subject: |
|
|
$Form1.AcceptButton = ""
$Button1.Visible = "False"
$Button1.Enabled = "False" _________________ Parents were invented to make children happy by giving them something to ignore. |
|
Back to top |
|
 |
Viggen KiXforms Regular

Joined: 28 Jun 2005 Posts: 40
|
Posted: Mon Nov 17, 2008 2:31 pm Post subject: |
|
|
Thanks for the reply, but it does not work.
If I print the result of $Button1.AcceptButton after I have done: $Form1.AcceptButton = ""
I still get "Kixforms.Button", and Button1 is still working with enter.
(although... strangely, Textbox2 works with CTRL + Enter ??)  |
|
Back to top |
|
 |
benny69 KiXforms Advocate


Joined: 30 Oct 2003 Posts: 567 Location: Lincoln, Ne
|
Posted: Mon Nov 17, 2008 4:19 pm Post subject: |
|
|
Hi Viggen,
Can you post your code, maybe I can help you out? _________________ Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta) |
|
Back to top |
|
 |
Viggen KiXforms Regular

Joined: 28 Jun 2005 Posts: 40
|
Posted: Mon Nov 17, 2008 7:52 pm Post subject: |
|
|
This script does what I want, except that I must click the button, instead of just pressing enter, after writing in Textbox1.
Code: | Break On
$System = CreateObject("Kixforms.System")
If Not $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0 ;FormStartPosition_Manual
$Form1.Size = $System.Size(168,277) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0
$TextBox1 = $System.TextBox()
$TextBox1.Left = 31
$TextBox1.Text = ""
$TextBox1.Top = 32
$nul = $Form1.Controls.Add($TextBox1)
$TextBox2 = $System.TextBox()
$TextBox2.AcceptsReturn = -1 ;True
$TextBox2.Left = 35
$TextBox2.Text = ""
$TextBox2.Top = 207
$TextBox2.Visible = 0
$nul = $Form1.Controls.Add($TextBox2)
$Button1 = $System.Button()
$Button1.FlatStyle = 3 ;System
$Button1.Left = 42
$Button1.Text = "Button1"
$Button1.Top = 70
$Button1.Click = "Function1()"
$nul = $Form1.Controls.Add($Button1)
$Form1.Show ;Displays the Form
While $Form1.Visible
$Nul = Execute($Form1.DoEvents())
Loop
Exit 0
Function Function1()
$TextBox1.Text = ""
$TextBox2.Visible = -1
$TextBox2.Focus
$TextBox2.KeyDown = "input()"
Endfunction
Function input()
Dim $Keydown, $nul
$Keydown = $TextBox2.KeyDownEventArgs.KeyCode
If $Keydown = 13
$nul = MessageBox('You wrote "' + $TextBox2.Text + '" in the textbox.','Info...',64)
$TextBox2.Text = ""
Endif
Endfunction |
|
|
Back to top |
|
 |
benny69 KiXforms Advocate


Joined: 30 Oct 2003 Posts: 567 Location: Lincoln, Ne
|
Posted: Mon Nov 17, 2008 8:55 pm Post subject: |
|
|
give this a try, see if it gets you what your looking for:
Code: |
Break On
$System = CreateObject("Kixforms.System")
If Not $System
$nul = MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.", "Error", 16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0 ;FormStartPosition_Manual
$Form1.Size = $System.Size(168, 277) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0
$TextBox1 = $System.TextBox()
$TextBox1.AcceptsReturn = -1 ;True
$TextBox1.Left = 31
$TextBox1.Text = ""
$TextBox1.Top = 32
$TextBox1.KeyDown = "Function1(0)"
$nul = $Form1.Controls.Add($TextBox1)
$TextBox2 = $System.TextBox()
$TextBox2.AcceptsReturn = -1 ;True
$TextBox2.Left = 35
$TextBox2.Text = ""
$TextBox2.Top = 207
$TextBox2.Visible = 0
$nul = $Form1.Controls.Add($TextBox2)
$Button1 = $System.Button()
$Button1.FlatStyle = 3 ;System
$Button1.Left = 42
$Button1.Text = "Button1"
$Button1.Top = 70
$Button1.Click = "Function1(1)"
$nul = $Form1.Controls.Add($Button1)
$ButtonClicked = 0
$Form1.Show ;Displays the Form
While $Form1.Visible
$Nul = Execute($Form1.DoEvents())
Loop
Exit 0
Function Function1($ButtonClicked)
$Keydown = $TextBox1.KeyDownEventArgs.KeyCode
If $Keydown = 13 Or $ButtonClicked = 1
$TextBox1.Text = ""
$TextBox1.Enabled = 0
$Button1.Enabled = 0
$TextBox2.Visible = -1
$TextBox2.Focus
$TextBox2.KeyDown = "input()"
EndIf
EndFunction
Function input()
Dim $Keydown, $nul
$Keydown = $TextBox2.KeyDownEventArgs.KeyCode
If $Keydown = 13
$nul = MessageBox('You wrote "' + $TextBox2.Text + '" in the textbox.', 'Info...', 64)
$TextBox2.Text = ""
EndIf
EndFunction
|
_________________ Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta) |
|
Back to top |
|
 |
Viggen KiXforms Regular

Joined: 28 Jun 2005 Posts: 40
|
Posted: Mon Nov 17, 2008 10:25 pm Post subject: |
|
|
Aaahh!
Of course!
Skip the .AcceptButton
Thanks Benny!
Works perfect!
Yet again you have saved me
/Viggen |
|
Back to top |
|
 |
Lonkero KiXforms Devotee


Joined: 13 Mar 2003 Posts: 1022 Location: Espoo, Finland
|
Posted: Tue Nov 18, 2008 7:24 pm Post subject: |
|
|
hmm...
if accept button is empty and you are not "tabbed" to the button, as example, if you are writing into the box, form should not do anything when pressing enter. _________________ Hammer |
|
Back to top |
|
 |
Lonkero KiXforms Devotee


Joined: 13 Mar 2003 Posts: 1022 Location: Espoo, Finland
|
Posted: Tue Nov 18, 2008 8:13 pm Post subject: |
|
|
oh, and that post was just to clarify that acceptbutton really does work. as it should.
what is weird is that button.acceptbutton has a value as it isn't supported in .net, as far as I know... _________________ Hammer |
|
Back to top |
|
 |
|