Notifications
Clear all
[Closed] Setting focus on a UI element on rollout open
Sep 07, 2005 10:13 am
Hi Guys,
I have a floating rollout with an edittext and a button. i want to do two things with this:
- the edittext should be focused when the rollout pops up, so the user can type right away before clicking inside the text field first
- if it’s possible the user should just have to press enter for the ok button to be pressed (possible?)
3 Replies
Sep 07, 2005 10:13 am
Hi Aeron,
Yes, and yes!
fn entmsg= messagebox "Enter has been pressed!" title:"Testbox"
rollout testbox "test"
(
button ent "Enter" width:275
edittext txt "Textbox"
on txt entered c do entmsg()
on ent pressed do entmsg()
on testbox open do
(
setfocus testbox.txt
)
)
createdialog testbox 300 50
/*
newroll=newrolloutfloater "Test box." 300 50
addrollout test newroll
*/
Although for some reason the ‘setfocus’ didn’t seem to work using a rollout floater (it should!)
Cheers,
J.
Sep 07, 2005 10:13 am
Neat, thats something thats been bugging me for a while that was actually one of the first scripts i ever wanted to do… to mimic the ‘/’ hotkey from combustion where you can type in a frame to jump to…
heres the script: adjust to fit your needs
-- SCRIPT: AEI_goToTime.ms Dave Buchhofer (dbuchhofer at gmail dot com)
-- Simple go to time script, mimic'ing the '/' hotkey in Combustion..
-- allowing you to set a hotkey to toggle the dialog on/off, type in a number
-- and go to that frame..
macroScript GoToTime category:"AEITools"
(
rollout setTime "setTime!@#"
(
spinner spn_time "Time" range:[ animationRange.start , animationRange.end , sliderTime] align:#left type:#integer fieldwidth:50
on spn_time entered do
(
sliderTime = spn_time.value
destroyDialog setTime
)
--------------------------------------------------------------------------------------
-- Position Saves and Reloads..
--------------------------------------------------------------------------------------
on setTime moved loc do
(
vsaifloaterpos = [ loc.x , loc.y ]
setIniSetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeX" (vsaifloaterpos.x as string)
setIniSetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeY" (vsaifloaterpos.y as string)
)
on setTime open do
(
--set focus of keyboard to the spinner editing..
setfocus setTime.spn_time
if (((getinisetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeX") as float) != "") then
(
setdialogpos setTime [ ((getinisetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeX") as float), \
((getinisetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeY") as float)]
)
)
--------------------------------------------------------------------------------------
)--end rollout definition
createdialog setTime width:100 pos:[ ((getinisetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeX") as float), \
((getinisetting "$max\vsaiFloaters.ini" "vsaiFloater" "setTimeY") as float)] \
style:#(#style_border, #style_toolwindow, #style_sysmenu)
)-- end macroscript
Sep 07, 2005 10:13 am
Hey thanks j_man, that’s great…very intuitive now
Vsai: i’m gonna give this a try right away, sounds useful!