spktoolbar: Fix action AND click events firing if both are assigned. Clean up click events from actions demo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6175 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-02-05 12:24:59 +00:00
parent fdee2dddbe
commit b12379211e
5 changed files with 18 additions and 27 deletions

View File

@ -417,8 +417,9 @@ procedure TSpkBaseButton.Click;
begin begin
// first call our own OnClick // first call our own OnClick
if Assigned(FOnClick) then if Assigned(FOnClick) then
FOnClick(Self); FOnClick(Self)
// then trigger the Action else
// otherwise trigger the action
if (not (csDesigning in ComponentState)) and (FActionLink <> nil) then if (not (csDesigning in ComponentState)) and (FActionLink <> nil) then
FActionLink.Execute(Self); FActionLink.Execute(Self);
end; end;
@ -704,10 +705,10 @@ begin
begin begin
if FButtonKind in [bkButton, bkButtonDropdown, bkToggle] then if FButtonKind in [bkButton, bkButtonDropdown, bkToggle] then
begin begin
Click;
FButtonState := bsBtnHottrack; FButtonState := bsBtnHottrack;
if Assigned(FToolbarDispatch) then if Assigned(FToolbarDispatch) then
FToolbarDispatch.NotifyVisualsChanged; FToolbarDispatch.NotifyVisualsChanged;
Click;
end else end else
if FButtonKind = bkDropdown then if FButtonKind = bkDropdown then
begin begin

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
@ -26,9 +26,10 @@
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/> <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="2"> <RequiredPackages Count="2">
<Item1> <Item1>

View File

@ -161,7 +161,7 @@ object Form1: TForm1
Appearance.Element.ActiveInnerDarkColor = 961020 Appearance.Element.ActiveInnerDarkColor = 961020
Appearance.Element.ActiveCaptionColor = 8405614 Appearance.Element.ActiveCaptionColor = 8405614
Appearance.Element.Style = esRounded Appearance.Element.Style = esRounded
TabIndex = 4 TabIndex = 0
Images = ImageList Images = ImageList
LargeImages = LargeImageList LargeImages = LargeImageList
Tabs = ( Tabs = (
@ -234,7 +234,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcOpen Action = AcOpen
Caption = 'Open file' Caption = 'Open file'
OnClick = AcOpenExecute
LargeImageIndex = 1 LargeImageIndex = 1
ButtonKind = bkButton ButtonKind = bkButton
end end
@ -243,7 +242,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcSave Action = AcSave
Caption = 'Save file' Caption = 'Save file'
OnClick = AcSaveExecute
LargeImageIndex = 2 LargeImageIndex = 2
ButtonKind = bkButton ButtonKind = bkButton
end end
@ -252,7 +250,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcQuit Action = AcQuit
Caption = 'Quit program' Caption = 'Quit program'
OnClick = AcQuitExecute
LargeImageIndex = 0 LargeImageIndex = 0
ButtonKind = bkButton ButtonKind = bkButton
end end
@ -321,7 +318,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcEditCut Action = AcEditCut
Caption = 'Cut' Caption = 'Cut'
OnClick = AcEditCutExecute
GroupBehaviour = gbSingleItem GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 3 ImageIndex = 3
@ -334,7 +330,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcEditCopy Action = AcEditCopy
Caption = 'Copy' Caption = 'Copy'
OnClick = AcEditCopyExecute
GroupBehaviour = gbSingleItem GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 4 ImageIndex = 4
@ -347,7 +342,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcEditPaste Action = AcEditPaste
Caption = 'Paste' Caption = 'Paste'
OnClick = AcEditPasteExecute
GroupBehaviour = gbSingleItem GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 5 ImageIndex = 5
@ -423,7 +417,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcBold Action = AcBold
Caption = 'Bold' Caption = 'Bold'
OnClick = AcBoldExecute
GroupBehaviour = gbBeginsGroup GroupBehaviour = gbBeginsGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 7 ImageIndex = 7
@ -436,7 +429,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcItalic Action = AcItalic
Caption = 'Italic' Caption = 'Italic'
OnClick = AcItalicExecute
GroupBehaviour = gbContinuesGroup GroupBehaviour = gbContinuesGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 8 ImageIndex = 8
@ -449,7 +441,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcUnderline Action = AcUnderline
Caption = 'Underline' Caption = 'Underline'
OnClick = AcUnderlineExecute
GroupBehaviour = gbEndsGroup GroupBehaviour = gbEndsGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 9 ImageIndex = 9
@ -462,7 +453,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcLeftJustify Action = AcLeftJustify
Caption = 'Left justify' Caption = 'Left justify'
OnClick = AcLeftJustifyExecute
GroupBehaviour = gbBeginsGroup GroupBehaviour = gbBeginsGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 10 ImageIndex = 10
@ -476,7 +466,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcCenter Action = AcCenter
Caption = 'Centered' Caption = 'Centered'
OnClick = AcCenterExecute
GroupBehaviour = gbContinuesGroup GroupBehaviour = gbContinuesGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 11 ImageIndex = 11
@ -490,7 +479,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcRightJustify Action = AcRightJustify
Caption = 'Right justify' Caption = 'Right justify'
OnClick = AcRightJustifyExecute
GroupBehaviour = gbEndsGroup GroupBehaviour = gbEndsGroup
HideFrameWhenIdle = False HideFrameWhenIdle = False
ImageIndex = 12 ImageIndex = 12
@ -565,7 +553,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcClassicalGUI Action = AcClassicalGUI
Caption = 'Classical' Caption = 'Classical'
OnClick = AcClassicalGUIExecute
State = cbUnchecked State = cbUnchecked
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
end end
@ -574,7 +561,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcRibbonGUI Action = AcRibbonGUI
Caption = 'Ribbon' Caption = 'Ribbon'
OnClick = AcRibbonGUIExecute
Checked = True Checked = True
State = cbChecked State = cbChecked
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
@ -604,7 +590,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcSaveNow Action = AcSaveNow
Caption = 'Save now' Caption = 'Save now'
OnClick = AcSaveNowExecute
GroupBehaviour = gbSingleItem GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 2 ImageIndex = 2
@ -617,7 +602,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcAutoSave Action = AcAutoSave
Caption = 'Autosave' Caption = 'Autosave'
OnClick = AcAutoSaveExecute
Checked = True Checked = True
State = cbChecked State = cbChecked
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
@ -685,7 +669,6 @@ object Form1: TForm1
Enabled = True Enabled = True
Action = AcAbout Action = AcAbout
Caption = 'About...' Caption = 'About...'
OnClick = AcAboutExecute
LargeImageIndex = 6 LargeImageIndex = 6
ButtonKind = bkButton ButtonKind = bkButton
end end
@ -1438,6 +1421,9 @@ object Form1: TForm1
0000000000000000000000000000000000000000002E00000033000000330000 0000000000000000000000000000000000000000002E00000033000000330000
002E000000000000000000000000 002E000000000000000000000000
} }
BitmapAdv = {
4C6900000000
}
end end
object LargeImageList: TImageList object LargeImageList: TImageList
Height = 32 Height = 32
@ -2343,5 +2329,8 @@ object Form1: TForm1
0009000000030000000000000000000000000000000000000000000000000000 0009000000030000000000000000000000000000000000000000000000000000
0000000000000000000000000000 0000000000000000000000000000
} }
BitmapAdv = {
4C6900000000
}
end end
end end

View File

@ -7,7 +7,7 @@ object AboutForm: TAboutForm
ClientHeight = 185 ClientHeight = 185
ClientWidth = 320 ClientWidth = 320
Position = poMainFormCenter Position = poMainFormCenter
LCLVersion = '1.7' LCLVersion = '1.9.0.0'
object Label1: TLabel object Label1: TLabel
Left = 0 Left = 0
Height = 30 Height = 30
@ -57,7 +57,7 @@ object AboutForm: TAboutForm
Cancel = True Cancel = True
Caption = 'Close' Caption = 'Close'
Default = True Default = True
ModalResult = 11 ModalResult = 1
TabOrder = 0 TabOrder = 0
end end
end end