New topic: FileType is not blocking Drag gesture
<http://forums.realsoftware.com/viewtopic.php?t=34341> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message basil.bourque Post subject: FileType is not blocking Drag gesturePosted: Sun Jun 20, 2010 7:43 pm Joined: Thu Apr 15, 2010 10:41 pm Posts: 32 Location: Seattle-area I want my TextField to accept a user's Drag & Drop of a file whose name ends in ".xyz". I procedurally create the FileType as a property on App: Quote:app.myFileType = New FileType app.myFileType.Name = "whatever" app.myFileType.Extensions = ".xyz" And I used it on the "Open" event handler of the TextField destination: Quote:me.AcceptFileDrop(app.myFileType) Good: This does turn on drag and drop feature. I can drop a file from the Finder (Mac file manager). Bad: I can drag any file. I expected my app to filter out dragging of files with the wrong extension in the name. --> Question #1: Am I missing the point of FileType.Extensions? Perhaps '.Extensions' works as a filter in File > Open dialogs but not for Drag and Drop? I found many forum postings on FileType, but not specifically on acting as a drag and drop filter. One workaround is to have the TextField's "DropObject" event handler examine the name of the file being dropped, and display an error message. But that is less than optimal, as it allows the user to fail. Better to refuse the drag. --> Question #2: As another workaround, can I write a handler for "DragOver" or "DrapEnter" events to check the file's name extension? How do I block accepting a drop, and prevent the visual cue (trim drawn around the field)? _________________ --Basil Bourque (Using REAL Studio 2010 release 2 with REAL Server 2009r1.2 on Mac OS X 10.6.2 & .3) Top pony Post subject: Re: FileType is not blocking Drag gesturePosted: Sun Jun 20, 2010 8:15 pm Joined: Sat Nov 11, 2006 2:43 pm Posts: 755 Location: DFW area, Texas, USA Take a look at the TextFields DragEnter event. You return True from this event to prevent the drop from occurring. Examine the file here and they will never get to drop the item. _________________ Fly like a mouse, run like a cushion, be the small bookcase. http://www.wish-sandwich.com Top mjh Post subject: Re: FileType is not blocking Drag gesturePosted: Mon Jun 21, 2010 3:50 am Joined: Sun Feb 19, 2006 3:10 pm Posts: 774 Location: Hamburg, Germany basil.bourque wrote:I want my TextField to accept a user's Drag & Drop of a file whose name ends in ".xyz". I procedurally create the FileType as a property on App: Quote:app.myFileType = New FileType app.myFileType.Name = "whatever" app.myFileType.Extensions = ".xyz" Youâve forgot to define the FileTypeâs MacType. I believe that if you donât specify a MacType, the FileType will accept files of any MacType, i.e. all files. FileTypes filter on MacType and extension, and it accepts a file if either of those filters does. _________________ Michael J. HuÃmann http://digicam-experts.de Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
