IDE: fpdoceditor: create button: show error message instead of disabling

git-svn-id: trunk@49620 -
This commit is contained in:
mattias 2015-08-08 10:37:14 +00:00
parent 95646ee93f
commit 0d54b4a4f4

View File

@ -277,7 +277,6 @@ begin
ShortLabel.Caption:=lisShort; ShortLabel.Caption:=lisShort;
LinkLabel.Caption:=lisLink; LinkLabel.Caption:=lisLink;
CreateButton.Caption := lisCodeHelpCreateButton; CreateButton.Caption := lisCodeHelpCreateButton;
CreateButton.Enabled:=false;
OpenXMLButton.Caption:=lisOpenXML; OpenXMLButton.Caption:=lisOpenXML;
OpenXMLButton.Enabled:=false; OpenXMLButton.Enabled:=false;
SaveButton.Caption := ''; SaveButton.Caption := '';
@ -875,8 +874,8 @@ begin
try try
EnabledState := (Element<>nil) and (Element.ElementNode<>nil); EnabledState := (Element<>nil) and (Element.ElementNode<>nil);
CreateButton.Enabled := (Element<>nil) and (Element.ElementNode=nil) //CreateButton.Enabled := (Element<>nil) and (Element.ElementNode=nil)
and (Element.ElementName<>''); // and (Element.ElementName<>'');
if EnabledState then if EnabledState then
begin begin
@ -1168,7 +1167,7 @@ begin
FOldVisualValues[i]:=''; FOldVisualValues[i]:='';
Modified := False; Modified := False;
CreateButton.Enabled:=false; //CreateButton.Enabled:=false;
OpenXMLButton.Enabled:=false; OpenXMLButton.Enabled:=false;
finally finally
Exclude(FFlags,fpdefReading); Exclude(FFlags,fpdefReading);
@ -1614,7 +1613,12 @@ end;
procedure TFPDocEditor.CreateButtonClick(Sender: TObject); procedure TFPDocEditor.CreateButtonClick(Sender: TObject);
begin begin
if (fChain=nil) or (fChain.Count=0) then exit; if ((fChain=nil) or (fChain.Count=0))
or (TCodeHelpElement(fChain[0]).ElementName='') then begin
IDEMessageDialog('Invalid Declaration','Please place the editor caret on an identifier. If this is a new unit, please save the file first.',
mtError,[mbOK]);
exit;
end;
CreateElement(fChain[0]); CreateElement(fChain[0]);
end; end;