#87954 - 2002-09-16 03:34 AM
Kixforms: OnKeyDown and KeyCode
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
OnKeyDown and KeyCode are the beginnings of the Kixforms keyboard interface. Two of a few methods and properties that will be making an appearance over the next few releases ...
OnKeyDown - triggered when the user depresses a key on the keyboard.
KeyCode - the keyboard code of the key that was pressed (not the ANSI char of the key that was pressed that will be implemented in another release). KeyCode is like the scan code of the key that was pressed.
For example, if one pressed ctrl-c while capturing KeyDowns and KeyCode, the result would this:
KeyCode = 17 (Ctrl) KeyCode = 67 (The A Key)
and for shift-K it would be:
KeyCode = 16 (Shift) KeyCode = 75 (The K Key)
So basically - it is used to capture RAW keyboard input. Heres a script that leverages this feature, it is inspired from a script written by another member of this board and submitted to me asking if this feature could be implemented.
It presents a ListBox on the left, a couple of buttons on the right, and a message and progressbar along the bottom. This script lets you select through the ListBox and choose a product to install, one may install a product by clicking the "Install" button - but the new OnKeyDown and KeyCode features allows one to select a ListBox entry and install by pressing the ENTER key.
code:
Break On $Form = CreateObject("Kixtart.Form") $Form.FontSize = 12 $Form.Size = 400,390 $Form.PrintXY(10,10,"Select a product and press enter:") $ListBox = $Form.ListBox $ListBox.Size = 200,205 $ListBox.Location = 10,50 $ListBox.FontName = Verdana $ListBox.OnKeyDown = "ListBox_KeyDown" For $i = 0 to 100 $ListBox.AddItem("Product #$i") Next $InstallButton = $Form.Button $InstallButton.Text = "Install" $InstallButton.Left = $ListBox.Right + 30 $InstallButton.Top = $ListBox.Top $InstallButton.OnClick = "InstallButton_Click()" $ExitButton = $Form.Button $ExitButton.Text = "Exit" $ExitButton.Left = $ListBox.Right + 30 $ExitButton.Top = $InstallButton.Bottom + 10 $ExitButton.OnClick = "ExitButton_Click()" $Msg = $Form.Label $Msg.Size = 370,25 $Msg.Location = 10,$ListBox.Bottom + 25 $Msg.Text = "Ready ..." $PBar = $Form.ProgressBar $PBar.Size = 370,25 $PBar.Location = 10,$Msg.Bottom + 5 $PBar.Min = 0 $PBar.Max = 100 $PBar.Value = 0 $Form.Center $Form.Show $ListBox.SetFocus $ListBox.ListIndex = 0 While $Form.Visible $=Execute($Form.DoEvents) Loop Exit 1 Function ListBox_KeyDown If $ListBox.KeyCode = 13 ; RETURN Install($ListBox.Value) $ListBox.SetFocus EndIf EndFunction Function InstallButton_Click() Install($ListBox.Value) EndFunction Function Install($Product) If $Product $Msg.Text = "Installing " + $Product For $i = 0 to $PBar.Max $PBar.Value = $i Sleep (0.025) Next $Msg.Text = "Ready ..." $PBar.Value = 0 EndIf EndFunction Function ExitButton_Click() $Form.Hide EndFunction
[ 16. September 2002, 04:13: Message edited by: Shawn ]
|
Top
|
|
|
|
#87955 - 2002-09-16 04:24 AM
Re: Kixforms: OnKeyDown and KeyCode
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Shawn, pressing the 'Enter' key isn't working for me. When I hit enter, the mouse cursor hide the the progress bar doesn't move. The mouse cursor reappears when I move it, but the Install() function isn't firing. It works if I hit the install button.
|
Top
|
|
|
|
#87957 - 2002-09-16 05:03 AM
Re: Kixforms: OnKeyDown and KeyCode
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
oh crap - i forgot - try it with Kixtart 4.12 Beta 1 ! Ruud fixed up some COM stuff that was identified ... this is one of them guess this is a bad thing ... can't have 2.0.5 tied just to 4.12 [ 16. September 2002, 05:04: Message edited by: Shawn ]
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 557 anonymous users online.
|
|
|