[Closed] keyboard value imput during script running
what script is working at this moment? mouse track function?
how do you want to activate the value input mode?
where does a user has to type a value? listener, popup window, or anything else
Is it possible without dialog? or at least to open just with an edittext where you could automatically put a value – without selecting this popup window and without pointing with the mouse inside edittext – let’s say I have
fn mouseCapture msg ir obj faceNum shift ctrl alt =
(
if msg == #freeMove then
(
myObj.pos = mapScreenToCP mouse.pos
myObj.pos.z = zzz
myObj.dir = [0,0,1]
if keyboard.altpressed then
-- popup window....
return #continue
)
)
that’s at least can be discussed and continued… first of all create a rollout with only one control… let’s say edittext. and if alt pressed popup this dialog in modal mode. using edittext entered event close the dialog
yes, in fact I have
fn mouseTrackFunction msg ir obj faceNum shift ctrl alt =
( …
I just don’t want the user to point any place on the screen to put the value, let’s call it distance!
During moving the object if I press some digits and hit enter, then I should get the distance value!
But if this is not possible, then popup window can be called when alt pressed!
Here I have something Barigazy made for groups
(
if go_Form != undefined do try(go_Form.close())catch()
global go_Form, goGUI = undefined
local movePos, go_TitleLbl, go_FlyPnl
struct goGUIStruct
(
formPosX, formPosY, formWidth, flowHorizontal, formTheme, btnProps, bgCol1, bgCol2, fgCol,
go_INI = getdir(#userScripts)+"\\artrenderGroups.ini",
fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b),
fn defPoint x y = (dotNetObject "System.Drawing.Point" x y),
fn defSize x y = (dotNetObject "System.Drawing.Size" x y),
--fn defRect x y w h = (dotNetObject "System.Drawing.Rectangle" x y w h),
fn setThemeColors theme &bgCol1 &bgCol2 &fgCol =
(
if theme == "dark" then (bgCol1 = defColor 68 68 68 ; bgCol2 = defColor 40 40 40 ; fgCol = defColor 196 196 196)
else (bgCol1 = defColor 198 198 198 ; bgCol2 = defColor 178 178 178 ; fgCol = defColor 40 40 40)
),
fn setParms &formWidth &btnProps state: =
(
if state then (formWidth = 80 ; btnProps = DataPair 10 #(3, 16, 271, 284))
else (formWidth = 38 ; btnProps = DataPair 6 #(3, 12, 20, 29))
),
fn getGO_INI iniFile =
(
if doesFileExist iniFile then
(
formPosX = (GetINISetting iniFile "goSettings" "formPosX") as integer
formPosY = (GetINISetting iniFile "goSettings" "formPosY") as integer
formTheme = GetINISetting iniFile "goSettings" "ColorTheme"
setThemeColors formTheme &bgCol1 &bgCol2 &fgCol
setParms &formWidth &btnProps state:(flowHorizontal = (GetINISetting iniFile "goSettings" "flowHorizontal") as BooleanClass)
)
else
(
formPosX = 50 ; formPosY = 110
formTheme = if ((colorMan.getColor #background) * 255.0).x < 100 then "dark" else "light"
setThemeColors formTheme &bgCol1 &bgCol2 &fgCol
setParms &formWidth &btnProps state:(flowHorizontal = true)
)
),
fn defForm dnForm = --main form
(
dnForm.ShowInTaskbar = false ; dnForm.Text = "" ; dnForm.ClientSize = defSize formWidth 16
dnForm.StartPosition = dnForm.StartPosition.Manual ; dnForm.DesktopLocation = defPoint formPosX formPosY
dnForm.FormBorderStyle = dnForm.FormBorderStyle.None ; dnForm.BackColor = defColor 0 0 0
dnForm.AutoSizeMode = dnForm.AutoSizeMode.GrowAndShrink ; dnForm.AutoSize = on
),
fn defTitleLbl bnrLbl frm txt: = -- baner title
(
bnrLbl.Size = defSize formWidth 16 ; bnrLbl.Location = defPoint 0 0 ; bnrLbl.Name = txt
bnrLbl.BackColor = bgCol2 ; bnrLbl.ForeColor = fgCol ; bnrLbl.Margin = MRG0000
bnrLbl.Font = Font ; bnrLbl.TextAlign = bnrLbl.TextAlign.MiddleCenter ; bnrLbl.Text = if formWidth < 40 then "" else txt
frm.Controls.add bnrLbl
),
fn defFlyPnl fPnl frm hFlow: = -- main container
(
fPnl.Size = defSize 0 0 ; fPnl.Location = defPoint 0 16 ; fPnl.Margin = MRG0000
fPnl.BackColor = frm.BackColor ; fPnl.AutoSizeMode = fPnl.AutoSizeMode.GrowAndShrink
fPnl.AutoSizeMode = fPnl.AutoSizeMode.GrowAndShrink ; fPnl.AutoSize = fPnl.WrapContents = on
fPnl.FlowDirection = if hFlow then fPnl.FlowDirection.LeftToRight else fPnl.FlowDirection.TopDown
frm.Height = fPnl.Height + 16
frm.Controls.add fPnl
),
fn defToolTip dnTT = (dnTT.AutoPopDelay = 10000 ; dnTT.InitialDelay = 2000 ; dnTT.ReshowDelay = 2000 ; dnTT), --tooltip
fn defBtn btn pnl image: asCB:off ttipTxt: = -- butons & checkbutton
(
btn.Size = defSize 36 35 ; btn.Margin = if pnl.FlowDirection == pnl.FlowDirection.TopDown then MRG1110 else MRG1101
btn.FlatStyle = btn.FlatStyle.Flat ; btn.FlatAppearance.BorderSize = 0
btn.BackColor = btn.FlatAppearance.BorderColor = bgCol1 ; btn.Image = image
if asCB do
(
btn.Appearance = btn.Appearance.Button ; btn.Margin = MRG1111
btn.FlatAppearance.CheckedBackColor = btn.FlatAppearance.MouseDownBackColor = bgCol2
)
(defToolTip (dotnetobject "ToolTip")).SetToolTip btn ttipTxt
pnl.Controls.add btn
),
on create do (this.getGO_INI this.go_INI)
)
goGUI = goGUIStruct()
go_Form = dotNetObject "Form" ; goGUI.defForm go_Form
go_TitleLbl = dotNetObject "Label" ; goGUI.defTitleLbl go_TitleLbl go_Form txt:"GroupOps"
go_FlyPnl = dotNetObject "FlowLayoutPanel" ; goGUI.defFlyPnl go_FlyPnl go_Form hFlow:goGUI.flowHorizontal
fn maxHW = (dotNetObject "maxCustomControls.win32HandleWrapper" (dotNetObject "System.IntPtr" (windows.getMaxHWND())))
fn bnrLbl_MouseDown s e = (movePos = [(mouse.screenpos.x - go_Form.DesktopLocation.x), (mouse.screenpos.y - go_Form.DesktopLocation.y)])
fn bnrLbl_MouseMove s e =
(
if e.Button == e.Button.Left and movePos != undefined do
(
s.TopLevelControl.DesktopLocation = goGUI.defPoint (mouse.screenpos.x - movePos.x) (mouse.screenpos.y - movePos.y)
)
)
fn bnrLbl_MouseUp s e = (movePos = undefined)
fn go_Form_close s e =
(
setINISetting goGUI.go_INI "goSettings" "formPosX" (s.Location.x as string)
setINISetting goGUI.go_INI "goSettings" "formPosY" (s.Location.y as string)
setINISetting goGUI.go_INI "goSettings" "ColorTheme" goGUI.formTheme
setINISetting goGUI.go_INI "goSettings" "flowHorizontal" (goGUI.flowHorizontal as string)
)
dotNet.addEventHandler go_TitleLbl "MouseDown" bnrLbl_MouseDown
dotNet.addEventHandler go_TitleLbl "MouseMove" bnrLbl_MouseMove
dotNet.addEventHandler go_Form "FormClosing" go_Form_close
dotNet.setLifetimeControl go_Form #dotnet
go_Form.Show (maxHW())
go_TitleLbl.Focus()
ok
)
I like it because it doesn’t display any window details! Should I use dotnet edittext?
When you press ALT(as Denis suggegst) to pop up the dialog with the edittext use setFocus so the mouse cursor will go to editText field and you can start typing the value. No need to click with the mouse in the edit text.
Instead of edit text you can use the spinner. Just hide the arrows and use the [i]on[/i] <spinner> [i]entered event.
[/i]Soemthing like this:
(
global rol_test
try(destroyDialog rol_test)catch()
rollout rol_test ""
(
spinner spn_Distance "" range:[-1e9,1e9,2] pos:[-2,1] fieldwidth:60 type:#worldunits
)
createdialog rol_test width:60 height:20 style:#()
setFocus rol_test.spn_Distance
)
Using the spinner:
- you can use type:#worldunits – no need to convert the values in the editText.
- you don’t have to check if the entered value is a number or not – in the editText you can enter letters by accident
Use this if you want the rollout to pop up where the mouse cursor is:
createdialog rol_test pos:mouse.screenpos width:60 height:20 style:#()