1. UpDown Control Help
- Posted by Lone_EverGreen_Ranger Sep 17, 2009
- 1161 views
- Last edited Sep 18, 2009
Hey Guys,
I was wondering how I would use an UpDown control to change the value inside an editbox. Here is my code
Hero_HP_Text = createEx(LText,"HP:",Tab_Hero,150,120,30,20,0,0), Hero_HP_Edit = createEx(EditText,"",Tab_Hero,190,120,40,22,0,0), Hero_HP_UpDn = createEx(UpDown,"",Tab_Hero,240,120,40,20,0,0)
What I am trying to do, is so that when the user clicks up, the value increases, and when the user clicks down, it decreases.
2. Re: UpDown Control Help
- Posted by dcole Sep 18, 2009
- 1203 views
From win32demos
without warning include win32lib.ew createForm( { "Window,UpDown Demo,width=300, height=200, bars=status", "EditText, name=Num, value=5,left=20, top=20, width=90, height=30", "UpDown, UD, left=20, top=20,width=10,height=*,position=5," & "range=(0,50000),buddy=Num," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT, UDS_ARROWKEYS)", "EditText, name=Num2, value=0,left=20, top=60, width=90, height=30", "UpDown, UD2, left=20,top=20,width=10,height=*,position=0," & "range=(-100,100),buddy=Num2," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS)" }) setAcceleration(getNameId("UD"), {{1,2}, {3,5}, {4, 10}, {5,100}, {6,1000}, {7,5000}}) procedure Scrolled(integer self, integer event, sequence parms) sequence text text = sprintf("Name=%s Value=%d", {getIdName(self), getScrollPos(self)}) showMessage(text) end procedure procedure AppCallback(integer self, integer event, sequence parms) if event = w32HGetHandler then -- parms[1] is the standard routine handler name -- in the form <eventname>_<controlname> -- eg. Click_PushBtn -- parms[3] is the control's name -- eg. "PushBtn" if find(parms[3], {"UD","UD2"}) then returnValue(routine_id("Scrolled")) else returnValue(routine_id(parms[1])) end if end if end procedure startApp(routine_id("AppCallback"))
Don Cole
3. Re: UpDown Control Help
- Posted by Lone_EverGreen_Ranger Sep 18, 2009
- 1198 views
Yea,
But that dosen't exactly answer my question.
4. Re: UpDown Control Help
- Posted by ghaberek (admin) Sep 18, 2009
- 1189 views
I believe you need to call setBuddy().
-Greg
5. Re: UpDown Control Help
- Posted by Lone_EverGreen_Ranger Sep 18, 2009
- 1200 views
I believe you need to call setBuddy().
-Greg
I've tried all different kinds of combinations with setBuddy and setAcceleration, nothing works. It won't show the value of the stat in the edit box. Here is what I want, when the user clicks on the UpDown control, I want the value of the stat to change inside of the editbox.
atom HP HP = 0 constant Hero_HP_Text = createEx(LText,"HP:",Tab_Hero,150,120,30,20,0,0), Hero_HP_Edit = createEx(EditText,"",Tab_Hero,190,120,40,22,0,0), Hero_HP_UpDn = createEx(UpDown,"",Tab_Hero,240,120,40,20,0,0) procedure Click_Hero_UpDn(integer self, integer event, sequence parm) --What would I need to do to make the value of the stat change --inside of the editbox, when the user clicks on the upDown control? end procedure setHandler(Hero_HP_UpDn,w32HClick,routine_id("Click_Hero_UpDn"))
6. Re: UpDown Control Help
- Posted by ghaberek (admin) Sep 18, 2009
- 1131 views
The UpDown control needs some flags (which is shown in the UpDown.EXW demo.
createForm( { "Window,UpDown Demo,width=300, height=200, bars=status", "EditText, name=Num, value=5,left=20, top=20, width=90, height=30", "UpDown, UD, left=20, top=20,width=10,height=*,position=5," & "range=(0,50000),buddy=Num," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT, UDS_ARROWKEYS)", "EditText, name=Num2, value=0,left=20, top=60, width=90, height=30", "UpDown, UD2, left=20,top=20,width=10,height=*,position=0," & "range=(-100,100),buddy=Num2," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS)" -- FLAGS })
Here's all the code you need to get an UpDown that will go from 1 to 100:
Hero_HP_UpDn = createEx(UpDown,"",Tab_Hero,0,0,0,0,w32or_all({UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS,UDS_WRAP}),0) setBuddy(Hero_HP_UpDn, Hero_HP_Edit) setAcceleration(Hero_HP_UpDn, {{1,2}, {3,5}, {4, 10}}) setScrollChange(Hero_HP_UpDn, 1, 5) setScrollRange(Hero_HP_UpDn, 1, 100)
-Greg
7. Re: UpDown Control Help
- Posted by Lone_EverGreen_Ranger Sep 18, 2009
- 1098 views
The UpDown control needs some flags (which is shown in the UpDown.EXW demo.
createForm( { "Window,UpDown Demo,width=300, height=200, bars=status", "EditText, name=Num, value=5,left=20, top=20, width=90, height=30", "UpDown, UD, left=20, top=20,width=10,height=*,position=5," & "range=(0,50000),buddy=Num," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT, UDS_ARROWKEYS)", "EditText, name=Num2, value=0,left=20, top=60, width=90, height=30", "UpDown, UD2, left=20,top=20,width=10,height=*,position=0," & "range=(-100,100),buddy=Num2," & "flags=(UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS)" -- FLAGS })
Here's all the code you need to get an UpDown that will go from 1 to 100:
Hero_HP_UpDn = createEx(UpDown,"",Tab_Hero,0,0,0,0,w32or_all({UDS_ALIGNRIGHT,UDS_SETBUDDYINT,UDS_ARROWKEYS,UDS_WRAP}),0) setBuddy(Hero_HP_UpDn, Hero_HP_Edit) setAcceleration(Hero_HP_UpDn, {{1,2}, {3,5}, {4, 10}}) setScrollChange(Hero_HP_UpDn, 1, 5) setScrollRange(Hero_HP_UpDn, 1, 100)
-Greg
Thank you, it works now, I just gotta edit some of my code now.