AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Action and checked button on toolbar

Ein Thema von WojTec · begonnen am 8. Feb 2012 · letzter Beitrag vom 8. Feb 2012
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Action and checked button on toolbar

  Alt 8. Feb 2012, 11:54
Delphi-Version: 2010
Previous I used toolbar buuttons without actions; group and autocheck was set in buttons; now I added actions (to add shortcuts) and moved code from OnClick to OnExecute and set autocheck and group properties, but can't 'unpress' (checked = false) button by mouse click (in Delphi can change Checked property). F1, please

Geändert von WojTec ( 8. Feb 2012 um 11:56 Uhr)
  Mit Zitat antworten Zitat
Steku

Registriert seit: 12. Mai 2008
181 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#2

AW: Action and checked button on toolbar

  Alt 8. Feb 2012, 12:22
untested:

in your onexecute use something like:

youraction.checked := not youraction.checked;

hope i've got you right...

Steku
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: Action and checked button on toolbar

  Alt 8. Feb 2012, 13:25
Nope, I tested it too - with this can't check.
So, whithout actions can check, but whith can't, why?

  Mit Zitat antworten Zitat
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
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: Action and checked button on toolbar

  Alt 8. Feb 2012, 14:30
Hm, I don't know why for you is ok when for me is not ok.
Acha, I used spTBXLib, maybe this is reason?
  Mit Zitat antworten Zitat
Benutzerbild von uligerhardt
uligerhardt

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

AW: Re: Action and checked button on toolbar

  Alt 8. Feb 2012, 14:49
Hm, I don't know why for you is ok when for me is not ok.
Acha, I used spTBXLib, maybe this is reason?
I added this:
Delphi-Quellcode:
  object SpTBXDock1: TSpTBXDock
    Left = 0
    Top = 29
    Width = 635
    Height = 25
    object SpTBXToolbar1: TSpTBXToolbar
      Left = 0
      Top = 0
      TabOrder = 0
      Caption = 'SpTBXToolbar1'
      object TBItem3: TTBItem
        Action = Action1
      end
      object TBItem2: TTBItem
        Action = Action2
      end
      object TBItem1: TTBItem
        Action = Action3
      end
    end
  end
Still works.
Uli Gerhardt
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz