1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #if __DESKTOP_TARGET__
- Namespace mojox
- Class FilePathField Extends DockingView
- Field FilePathChanged:Void()
- Method New( path:String="",fileType:FileType=std.filesystem.FileType.File )
-
- _fileType=fileType
- _textField=New TextField( path )
-
- _textField.TextChanged+=Lambda()
-
- FilePathChanged()
- End
- _pathButton=New PushButton( "..." )
-
- _pathButton.Clicked=Lambda()
-
- New Fiber( Lambda()
-
- Local future:=New Future<String>
-
- App.Idle+=Lambda()
- If _fileType=FileType.Directory
- future.Set( requesters.RequestDir( "Select Directory",_textField.Text ) )
- Else
- future.Set( requesters.RequestFile( "Select File",_filter,False,_textField.Text ) )
- Endif
- End
-
- Local path:=future.Get()
- If Not path Return
-
- _textField.Text=path
-
- FilePathChanged()
- End )
- End
-
- AddView( _pathButton,"right" )
- ContentView=_textField
- MaxSize=New Vec2i( 320,0 )
- End
-
- Property FileFilter:String()
-
- Return _filter
-
- Setter( filter:String )
-
- _filter=filter
- End
-
- Property FilePath:String()
-
- Return _textField.Text
-
- Setter( path:String )
-
- _textField.Text=path
- End
-
- Property FileType:FileType()
-
- Return _fileType
-
- Setter( fileType:FileType )
-
- _fileType=fileType
- End
-
- Private
- Field _filter:String
- Field _textField:TextField
- Field _pathButton:PushButton
- Field _fileType:FileType
- End
- #endif
|