GUI component interaction: Difference between revisions

FutureBasic solution added
m (syntax highlighting fixup automation)
(FutureBasic solution added)
Line 1,186:
End
</syntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_window = 1
begin enum 1
_valLabel
_valFld
_incBtn
_rndBtn
end enum
 
_confirmAlert = 1
 
void local fn BuildWindow
window _window, @"GUI Components", (0,0,214,100), NSWindowStyleMaskTitled
textlabel _valLabel, @"Value:", (20,61,42,16)
textfield _valFld,, @"0", (68,59,126,21)
ControlSetFormat( _valFld, @"0123456789", YES, 3, 0 )
button _incBtn,,, @"Increment", (13,13,95,32)
button _rndBtn,,, @"Random", (106,13,95,32)
WindowMakeFirstResponder( _window, _valFld )
end fn
 
void local fn DoAppEvent( ev as long )
select ( ev )
case _appDidFinishLaunching
random
fn BuildWindow
end select
end fn
 
void local fn DoDialog( ev as long, tag as long )
select ( ev )
case _btnClick
select ( tag )
case _incBtn
long value = fn ControlIntegerValue( _valFld ) + 1
if ( value > 999 ) then value = 999
ControlSetStringValue( _valFld, fn StringWithFormat(@"%ld",value) )
case _rndBtn
long response = alert _confirmAlert,, @"Reset field", @"Do you want to reset the field to a random value?", @"OK;Cancel"
if ( response == NSAlertFirstButtonReturn )
ControlSetStringValue( _valFld, fn StringWithFormat(@"%ld",rnd(999)) )
end if
end select
end select
end fn
 
on appevent fn DoAppEvent
on dialog fn DoDialog
 
HandleEvents
</syntaxhighlight>
 
{{out}}
[[File:FB_GUIComponentInteraction.png]]
 
=={{header|Gambas}}==
416

edits