Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
Accepted Solution

How to create delete confirmation dialog

Hello everyone. I am using a DataGrid to display files and folders and have buttons to add folder, delete folder, delete file but I want to add a confirmation popup dialog for when a delete button is pressed. I found one example but it uses the MX FileSystemDataGrid and I couldn't figure out how to extrapolate from that example and apply it to my use. Below is my code, hoping someone can suggest how I can do it.

 

protected function deleteFolder_clickHandler(event:MouseEvent):void
			{
				var dir:File = File.documentsDirectory.resolvePath(folderName.text);
				dir.deleteDirectory();
				folderName.text = "";
				file.getDirectoryListingAsync();
				folderList.refresh();
				list.dataProvider = folderList;
			}
			
			protected function deleteFile_clickHandler(event:MouseEvent):void
			{
				var delFile:File = this.filelist.selectedItem.file as File;
				delFile.deleteFile();
				currentFile.getDirectoryListingAsync();
				fileList.removeAll();
				fileList.refresh();
				filelist.dataProvider = fileList;
				
			}

 

BlackBerry Development Advisor
Posts: 834
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: How to create delete confirmation dialog

You have those methods set up as the event handlers for the delete buttons. Why don't you create a different method to sit in-between? So your click handler for the delete button goes to a new showConfirmationDialog() method, with an okay button. The click handler for the okay button should be your current delete method. Make sense?

Tim Windsor
Open Source Technical Lead
Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Re: How to create delete confirmation dialog

So build an alert dialog rather than just using Alert.dialog?
BlackBerry Development Advisor
Posts: 834
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: How to create delete confirmation dialog

You could do either approach. There's the PromptDialog class which would be the native dialog control to use.

Tim Windsor
Open Source Technical Lead
Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Re: How to create delete confirmation dialog

Thanks I'm going to take a look at this class.