Einzelnen Beitrag anzeigen

Benutzerbild von uligerhardt
uligerhardt

Registriert seit: 19. Aug 2004
Ort: Hof/Saale
1.735 Beiträge
 
Delphi 2007 Professional
 
#4

AW: Action and checked button on toolbar

  Alt 8. Feb 2012, 14:11
I tested it with this DFM:
Delphi-Quellcode:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 337
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ToolBar1: TToolBar
    Left = 0
    Top = 0
    Width = 635
    Height = 29
    ButtonHeight = 21
    ButtonWidth = 43
    Caption = 'ToolBar1'
    ShowCaptions = True
    TabOrder = 0
    object ToolButton1: TToolButton
      Left = 0
      Top = 0
      Action = Action1
    end
    object ToolButton2: TToolButton
      Left = 43
      Top = 0
      Action = Action2
    end
    object ToolButton3: TToolButton
      Left = 86
      Top = 0
      Action = Action3
    end
  end
  object ActionList1: TActionList
    Left = 312
    Top = 176
    object Action1: TAction
      Caption = 'Action1'
      Checked = True
      GroupIndex = 1
      OnExecute = Action1Execute
    end
    object Action2: TAction
      Caption = 'Action2'
      GroupIndex = 1
      OnExecute = Action1Execute
    end
    object Action3: TAction
      Caption = 'Action3'
      GroupIndex = 1
      OnExecute = Action1Execute
    end
  end
end
and this OnExecute handler:
Delphi-Quellcode:
procedure TForm1.Action1Execute(Sender: TObject);
var
  actn: TAction absolute Sender;
begin
  Assert(Sender is TAction);
  actn.Checked := not actn.Checked;
end;
and I can press and unpress just fine.
Uli Gerhardt
  Mit Zitat antworten Zitat