BBjFileChooser::setRestrictedDirectory

Description

In BBj 16.0 and higher, this method restricts the user to a selected parent directory in a server-side BBjFileChooser.

Syntax

Return Value

Method

void

setRestrictedDirectory(string directory)

Parameters

Variable

Description

directory

The parent directory that the user should be restricted to in the server-side BBjFileChooser.

Return Value

None.

Remarks

When a directory restriction is in effect, any attempt by the user to navigate to a directory above the restricted directory in the filesystem hierarchy will be ignored.

Example

rem ' setRestrictedDirectory
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "setRestrictedDirectory"
window! = sysgui!.addWindow(50,50,600,500,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
directory$ = dsk("") + dir("")
chooser! = window!.addFileChooser(101,25,25,550,400,directory$,$$)
vector! = bbjapi().makeVector()
vector!.add("*.gif")
vector!.add("*.jpg")
vector!.add("*.png")
vector!.add("*.bmp")
vector!.add("*.ico")
chooser!.addFileFilter("Image Files", vector!)
chooser!.addFileFilter("Text Files", "*.txt")
chooser!.setActiveFileFilter("Text Files")
chooser!.setCallback(chooser!.ON_FILECHOOSER_CHANGE,"change")
chooser!.setCallback(chooser!.ON_FILECHOOSER_APPROVE,"approve")
chooser!.setCallback(chooser!.ON_FILECHOOSER_CANCEL,"cancel")
chooser!.setCallback(chooser!.ON_FILECHOOSER_FILTER,"filter")
chooser!.setCallback(chooser!.ON_GAINED_FOCUS,"event")
chooser!.setCallback(chooser!.ON_LOST_FOCUS,"event")
chooser!.setCallback(chooser!.ON_MOUSE_ENTER,"event")
chooser!.setCallback(chooser!.ON_MOUSE_EXIT,"event")
chooser!.setCallback(chooser!.ON_POPUP_REQUEST,"event")
chooser!.setCallback(chooser!.ON_RIGHT_MOUSE_DOWN,"event")
set! = window!.addButton(1,25,450,200,25,"Restrict user to current directory",$$)
set!.setCallback(set!.ON_BUTTON_PUSH,"restrict")
clr! = window!.addButton(2,250,450,200,25,"Clear directory restriction",$$)
clr!.setCallback(set!.ON_BUTTON_PUSH,"unrestrict")
process_events
eoj:
  release
restrict:
  dir$ = chooser!.getCurrentDirectory()
  print "setRestrictedDirectory ",dir$
  chooser!.setRestrictedDirectory(dir$)
  window!.setTitle("User is restricted to "+chooser!.getRestrictedDirectory())
return
unrestrict:
  dir$ = ""
  print "setRestrictedDirectory ",dir$
  chooser!.setRestrictedDirectory(dir$)
  window!.setTitle("User is not restricted")
return
change:
  event! = sysgui!.getLastEvent()
  event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
  print event$,": ",event!.getSelectedFiles(),"; ",chooser!.getText()
return
approve:
  event! = sysgui!.getLastEvent()
  event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
  print event$,": ",event!.getSelectedFiles(),"; ",chooser!.getText()
return
cancel:
  event! = sysgui!.getLastEvent()
  event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
  print event$,"; ",chooser!.getText()
return
filter:
  event! = sysgui!.getLastEvent()
  event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
  print event$,": ",event!.getActiveFileFilter(),"; ",chooser!.getText()
return
event:
  event! = sysgui!.getLastEvent()
  event$ = event!.toString(), event$ = event$(1,pos("@"=event$)-1)
  control! = event!.getControl()
  control$ = control!.toString(), control$ = control$(1,pos("@"=control$)-1)
  print control$," ",event$,"; ",chooser!.getText()
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjFileChooser

BBjFileChooser::getRestrictedDirectory

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.