83 lines
1.9 KiB
Text
83 lines
1.9 KiB
Text
_window = 1
|
|
begin enum 1
|
|
_inputFld
|
|
_incBtn
|
|
_decBtn
|
|
end enum
|
|
|
|
void local fn BuildWindow
|
|
window _window, @"GUI enabling/disabling of controls", (0,0,350,150), NSWindowStyleMaskTitled
|
|
|
|
textfield _inputFld,, @"0", (160,78,30,21)
|
|
ControlSetAlignment( _inputFld, NSTextAlignmentCenter )
|
|
|
|
button _incBtn,,, @"Increment", (75,43,101,32)
|
|
|
|
button _decBtn, NO,, @"Decrement", (174,43,101,32)
|
|
end fn
|
|
|
|
void local fn InputAction
|
|
long value = fn ControlIntegerValue( _inputFld )
|
|
|
|
if ( value < 0 or value > 10 ) then value = 0
|
|
textfield _inputFld,, str(value)
|
|
|
|
select ( value )
|
|
case 0
|
|
TextFieldSetEditable( _inputFld, YES )
|
|
button _incBtn, YES
|
|
button _decBtn, NO
|
|
case 10
|
|
TextFieldSetEditable( _inputFld, NO )
|
|
WindowMakeFirstResponder( _window, 0 )
|
|
button _incBtn, NO
|
|
button _decBtn, YES
|
|
case else
|
|
TextFieldSetEditable( _inputFld, NO )
|
|
WindowMakeFirstResponder( _window, 0 )
|
|
button _incBtn, YES
|
|
button _decBtn, YES
|
|
end select
|
|
end fn
|
|
|
|
void local fn IncrementAction
|
|
long value = fn ControlIntegerValue( _inputFld ) + 1
|
|
|
|
textfield _inputFld,, str(value)
|
|
TextFieldSetEditable( _inputFld, NO )
|
|
WindowMakeFirstResponder( _window, 0 )
|
|
|
|
if ( value >= 10 ) then button _incBtn, NO
|
|
|
|
if ( value > 0 ) then button _decBtn, YES
|
|
end fn
|
|
|
|
void local fn DecrementAction
|
|
long value = fn ControlIntegerValue( _inputFld ) - 1
|
|
|
|
textfield _inputFld,, str(value)
|
|
|
|
if ( value < 10 ) then button _incBtn, YES
|
|
|
|
if ( value == 0 )
|
|
button _decBtn, NO
|
|
TextFieldSetEditable( _inputFld, YES )
|
|
end if
|
|
end fn
|
|
|
|
void local fn DoDialog( ev as long, tag as long )
|
|
select ( ev )
|
|
case _btnClick
|
|
select ( tag )
|
|
case _inputFld : fn InputAction
|
|
case _incBtn : fn IncrementAction
|
|
case _decBtn : fn DecrementAction
|
|
end select
|
|
end select
|
|
end fn
|
|
|
|
fn BuildWindow
|
|
|
|
on dialog fn DoDialog
|
|
|
|
HandleEvents
|