[Plib-devel] PUI File Browser Implementation
Brought to you by:
sjbaker
From: John F. F. <joh...@eg...> - 2000-08-01 13:49:40
|
I made a file browser out of a "puLargeInput" widget. The "puLargeInput" is essentially a multiple-line input box with a slider to the right and a slider below it. (The "puText" widget won't work because it doesn't support mouse hits.) The file browser doesn't return a file name like Steve wanted it to ( filename = puFileBrowser ("*.*"); ), but it does display a list of files and allow the user to pick one. I found that I had to save the widget and a callback in order to let the program remember what it wanted the file name for. I don't think it's very elegant, but it works; if there is a better way I would like to hear about it. My user interface has a button that allows the user to read the text from a file into a "puLargeInput" widget. The callback for this button calls a function that opens the file browser window. The callback passes to this function a character string to hold the file name when the user has selected it, a pointer to a function to be called when the user has selected the file name (I call this the "action function"), and the pointer to the "puLargeInput" widget which is to receive the text from the file (the "receiving widget"). The file browser window contains a second "puLargeInput" widget to hold all the files, a "puInput" widget to hold the selected file name, and an "OK" button. (It also contains a few other widgets which are not relevant to the present discussion.) The "puLargeInput" widget gets a list of files written into it. If the user clicks in the "puLargeInput" widget, the file name which he clicks on gets written into the "puInput" widget. When he clicks on the "OK" button, and if the name in the "puInput" widget is a regular file name, the program calls the action function and passes to it the pointer to the receiving widget. I'm not sure if this explanation is clear. If there is any interest in further details, ask me for them and I'll do my best. John F. Fay joh...@eg... |