From b12379211ee7e6b5908f0ef91e4fc67c2b7e9fdf Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 5 Feb 2018 12:24:59 +0000 Subject: [PATCH] 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 --- .../spktoolbar/SpkToolbar/spkt_Buttons.pas | 7 ++--- .../spktoolbar/demos/actions/project1.lpi | 9 ++++--- components/spktoolbar/demos/actions/unit1.lfm | 25 +++++------------- components/spktoolbar/demos/actions/unit2.lfm | 4 +-- .../spktoolbar/demos/basic/Project1.res | Bin 139052 -> 138932 bytes 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas index 1fdf26f31..5ae104df1 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas @@ -417,8 +417,9 @@ procedure TSpkBaseButton.Click; begin // first call our own OnClick if Assigned(FOnClick) then - FOnClick(Self); - // then trigger the Action + FOnClick(Self) + else + // otherwise trigger the action if (not (csDesigning in ComponentState)) and (FActionLink <> nil) then FActionLink.Execute(Self); end; @@ -704,10 +705,10 @@ begin begin if FButtonKind in [bkButton, bkButtonDropdown, bkToggle] then begin - Click; FButtonState := bsBtnHottrack; if Assigned(FToolbarDispatch) then FToolbarDispatch.NotifyVisualsChanged; + Click; end else if FButtonKind = bkDropdown then begin diff --git a/components/spktoolbar/demos/actions/project1.lpi b/components/spktoolbar/demos/actions/project1.lpi index 0d5ae062f..2c16c7aee 100644 --- a/components/spktoolbar/demos/actions/project1.lpi +++ b/components/spktoolbar/demos/actions/project1.lpi @@ -1,7 +1,7 @@ - + @@ -26,9 +26,10 @@ - - - + + + + diff --git a/components/spktoolbar/demos/actions/unit1.lfm b/components/spktoolbar/demos/actions/unit1.lfm index 68739aa42..aa15f8159 100644 --- a/components/spktoolbar/demos/actions/unit1.lfm +++ b/components/spktoolbar/demos/actions/unit1.lfm @@ -161,7 +161,7 @@ object Form1: TForm1 Appearance.Element.ActiveInnerDarkColor = 961020 Appearance.Element.ActiveCaptionColor = 8405614 Appearance.Element.Style = esRounded - TabIndex = 4 + TabIndex = 0 Images = ImageList LargeImages = LargeImageList Tabs = ( @@ -234,7 +234,6 @@ object Form1: TForm1 Enabled = True Action = AcOpen Caption = 'Open file' - OnClick = AcOpenExecute LargeImageIndex = 1 ButtonKind = bkButton end @@ -243,7 +242,6 @@ object Form1: TForm1 Enabled = True Action = AcSave Caption = 'Save file' - OnClick = AcSaveExecute LargeImageIndex = 2 ButtonKind = bkButton end @@ -252,7 +250,6 @@ object Form1: TForm1 Enabled = True Action = AcQuit Caption = 'Quit program' - OnClick = AcQuitExecute LargeImageIndex = 0 ButtonKind = bkButton end @@ -321,7 +318,6 @@ object Form1: TForm1 Enabled = True Action = AcEditCut Caption = 'Cut' - OnClick = AcEditCutExecute GroupBehaviour = gbSingleItem HideFrameWhenIdle = True ImageIndex = 3 @@ -334,7 +330,6 @@ object Form1: TForm1 Enabled = True Action = AcEditCopy Caption = 'Copy' - OnClick = AcEditCopyExecute GroupBehaviour = gbSingleItem HideFrameWhenIdle = True ImageIndex = 4 @@ -347,7 +342,6 @@ object Form1: TForm1 Enabled = True Action = AcEditPaste Caption = 'Paste' - OnClick = AcEditPasteExecute GroupBehaviour = gbSingleItem HideFrameWhenIdle = True ImageIndex = 5 @@ -423,7 +417,6 @@ object Form1: TForm1 Enabled = True Action = AcBold Caption = 'Bold' - OnClick = AcBoldExecute GroupBehaviour = gbBeginsGroup HideFrameWhenIdle = False ImageIndex = 7 @@ -436,7 +429,6 @@ object Form1: TForm1 Enabled = True Action = AcItalic Caption = 'Italic' - OnClick = AcItalicExecute GroupBehaviour = gbContinuesGroup HideFrameWhenIdle = False ImageIndex = 8 @@ -449,7 +441,6 @@ object Form1: TForm1 Enabled = True Action = AcUnderline Caption = 'Underline' - OnClick = AcUnderlineExecute GroupBehaviour = gbEndsGroup HideFrameWhenIdle = False ImageIndex = 9 @@ -462,7 +453,6 @@ object Form1: TForm1 Enabled = True Action = AcLeftJustify Caption = 'Left justify' - OnClick = AcLeftJustifyExecute GroupBehaviour = gbBeginsGroup HideFrameWhenIdle = False ImageIndex = 10 @@ -476,7 +466,6 @@ object Form1: TForm1 Enabled = True Action = AcCenter Caption = 'Centered' - OnClick = AcCenterExecute GroupBehaviour = gbContinuesGroup HideFrameWhenIdle = False ImageIndex = 11 @@ -490,7 +479,6 @@ object Form1: TForm1 Enabled = True Action = AcRightJustify Caption = 'Right justify' - OnClick = AcRightJustifyExecute GroupBehaviour = gbEndsGroup HideFrameWhenIdle = False ImageIndex = 12 @@ -565,7 +553,6 @@ object Form1: TForm1 Enabled = True Action = AcClassicalGUI Caption = 'Classical' - OnClick = AcClassicalGUIExecute State = cbUnchecked TableBehaviour = tbBeginsRow end @@ -574,7 +561,6 @@ object Form1: TForm1 Enabled = True Action = AcRibbonGUI Caption = 'Ribbon' - OnClick = AcRibbonGUIExecute Checked = True State = cbChecked TableBehaviour = tbBeginsRow @@ -604,7 +590,6 @@ object Form1: TForm1 Enabled = True Action = AcSaveNow Caption = 'Save now' - OnClick = AcSaveNowExecute GroupBehaviour = gbSingleItem HideFrameWhenIdle = True ImageIndex = 2 @@ -617,7 +602,6 @@ object Form1: TForm1 Enabled = True Action = AcAutoSave Caption = 'Autosave' - OnClick = AcAutoSaveExecute Checked = True State = cbChecked TableBehaviour = tbBeginsRow @@ -685,7 +669,6 @@ object Form1: TForm1 Enabled = True Action = AcAbout Caption = 'About...' - OnClick = AcAboutExecute LargeImageIndex = 6 ButtonKind = bkButton end @@ -1438,6 +1421,9 @@ object Form1: TForm1 0000000000000000000000000000000000000000002E00000033000000330000 002E000000000000000000000000 } + BitmapAdv = { + 4C6900000000 + } end object LargeImageList: TImageList Height = 32 @@ -2343,5 +2329,8 @@ object Form1: TForm1 0009000000030000000000000000000000000000000000000000000000000000 0000000000000000000000000000 } + BitmapAdv = { + 4C6900000000 + } end end diff --git a/components/spktoolbar/demos/actions/unit2.lfm b/components/spktoolbar/demos/actions/unit2.lfm index dd45b00eb..090b3cccc 100644 --- a/components/spktoolbar/demos/actions/unit2.lfm +++ b/components/spktoolbar/demos/actions/unit2.lfm @@ -7,7 +7,7 @@ object AboutForm: TAboutForm ClientHeight = 185 ClientWidth = 320 Position = poMainFormCenter - LCLVersion = '1.7' + LCLVersion = '1.9.0.0' object Label1: TLabel Left = 0 Height = 30 @@ -57,7 +57,7 @@ object AboutForm: TAboutForm Cancel = True Caption = 'Close' Default = True - ModalResult = 11 + ModalResult = 1 TabOrder = 0 end end diff --git a/components/spktoolbar/demos/basic/Project1.res b/components/spktoolbar/demos/basic/Project1.res index f6e8499568f21121986c715951291349244aeef3..877868cb4251927ab961b2295948c0d753ecb7cd 100644 GIT binary patch delta 33 pcmZ3pk7LVTjtL5kmKzn#*(P6NQ(|Oj{>;|?nT>J#XEr8F2>{SX3v&Pf delta 61 zcmdn8mt)O7jtL5kn>Q+&vrRt2>Lh7srXQY}my%yz9GqHGl9`uYtYpW_rJ$fN*^