BBjFileChooser::setSelectedFiles

Description

In BBj 7.0 and higher, this method selects a list of files in the BBjFileChooser.

Syntax

Return Value

Method

void

setSelectedFiles(BBjVector filenames!)

Parameters

Variable

Description

filenames!   

A vector containing strings with the absolute names of files to select.

Return Value

None.

Remarks

Attempting to set a list of selected files when isMultiSelectionEnabled() is false will result in an !ERROR=17.

 

BUI logo

The BUI client-side fileopen file chooser ignores this setting.

See BUI: Interacting with client files for a detailed discussion of the BUI client-side file choosers.

Example

rem 'sg = unt

open(sg)"X0"

api! = BBjAPI()
sg! = api!.getSysGui()
window! = sg!.addWindow(100, 100, 500, 350, "File Chooser", $00010083$, $$)
pwd$ = DIR("")
fc! = window!.addFileChooser(101, 0, 0, 500, 300, pwd$, $0004$)
selectButton! = window!.addButton(102, 200, 310, 100, 30, "Select files")
parentButton! = window!.addButton(103, 310, 310, 100, 30, "Parent Directory")
fc!.setMultiSelectionEnabled(1)
fc!.setFileSelectionMode(fc!.FILES_AND_DIRECTORIES)

selectButton!.setCallback(api!.ON_BUTTON_PUSH, "SELECT_FILES")
parentButton!.setCallback(api!.ON_BUTTON_PUSH, "PARENT_DIR")
fc!.setCallback(api!.ON_FILECHOOSER_APPROVE, "DO_APPROVE")
fc!.setCallback(api!.ON_FILECHOOSER_CANCEL, "DO_CANCEL")

window!.setCallback(api!.ON_CLOSE, "DO_CLOSE")

process_events

DO_CLOSE:
release

SELECT_FILES:
    dirCh = UNT
    pwd$ = fc!.getCurrentDirectory()
    open(dirCh)pwd$
    readrecord(dirCh)dummy$
    readrecord(dirCh)dummy$
    readrecord(dirCh)file1$
    readrecord(dirCh)file2$
    vec! = api!.makeVector()
    vec!.addItem(pwd$ + "/" + file1$)
    vec!.addItem(pwd$ + "/" + file2$)
    fc!.setSelectedFiles(vec!)
return

PARENT_DIR:
    fc!.changeToParentDirectory()
return

DO_APPROVE:
    ev! = BBjAPI().getLastEvent()
    vec! = ev!.getSelectedFiles()
    for idx = 0 to vec!.size() - 1
        if (vec!.size() > 0)
            file$ = vec!.get(idx)
            PRINT file$
        endif
    next idx
    window!.destroy()
END

DO_DIALOG_CANCEL:
    fc!.cancelSelection()
return

DO_CANCEL:
    PRINT "File selection cancelled"
END

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjFileChooser

   BBjFileChooser::getSelectedFile

   BBjFileChooser::getSelectedFiles

   BBjFileChooser::setSelectedFile

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