Index: /CKEditor/branches/prototype/_source/plugins/forms/dialogs/button.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/forms/dialogs/button.js	(revision 2772)
+++ /CKEditor/branches/prototype/_source/plugins/forms/dialogs/button.js	(revision 2773)
@@ -31,4 +31,24 @@
 	};
 
+	// Function called in onShow to load selected element.
+	var loadLink = function( editor, selection, ranges, element ){
+
+		// Read attributes.
+		var type = element.getAttribute( 'type' );
+		var name = element.getAttribute( 'name' );
+		var value = element.getAttribute( 'value' );
+
+		// Fill out all fields.
+		this.setValueOf( 'info', 'txtName', name );
+		this.setValueOf( 'info', 'txtValue', value );
+		this.setValueOf( 'info', 'txtType', type );
+		
+		this.saveSelection();
+		this.editMode = true;
+		this.editObj = element;
+
+		return false;
+	};
+	
 	return {
 		title : editor.lang.buttonProp,
@@ -38,12 +58,14 @@
 		onOk: function( data )
 		{
-			for( var name in this.changedAttibutes )
+			for ( var name in this.changedAttibutes )
 			{
-				this.editObj.setAttribute(name, this.changedAttibutes[ name ] );
+				this.editObj.setAttribute( name, this.changedAttibutes[ name ] );
 			}
 
-			if( this.editMode == false )
-			{
+			if ( this.editMode == false )
+			{			
+				// Doesn't work with IE.
 				this.restoreSelection();
+				this.clearSavedSelection();
 				editor.insertElement( this.editObj );
 			}
@@ -52,12 +74,34 @@
 		onShow: function()
 		{
+			// Default: create a new element.
 			this.editMode = false;
+			
+			// IE BUG: Selection must be in the editor for getSelection() to work.
+			this.restoreSelection();
 
-			/*
-			Check selection.
-			Fill this.editObj if the BUTTON element is selected.
-			*/
+			var editor = this.getParentEditor(),
+				selection = editor.getSelection(),
+				ranges = selection.getRanges();
+				
+			// Check selection. Fill in all the relevant fields if there's already one link selected.
+			if ( ranges.length == 1 )
+			{
+				ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT );
 
-			if( this.editMode == false )	//New object.
+				var rangeRoot = ranges[0].getCommonAncestor( true );
+				var element = rangeRoot.getAscendant( 'input', true );
+				if ( element && element.getAttribute( 'type' ) )
+				{
+					var type = element.getAttribute( 'type' );
+					if ( type == "button" || type == "reset" || type == "submit" )
+					{
+						loadLink.apply( this, [ editor, selection, ranges, element ] );
+						selection.selectElement( element );
+					}
+
+				}
+			}
+
+			if ( this.editMode == false )	//New object.
 			{
 				this.editObj = editor.document.createElement( 'input' );
