[英]OSX Yosemite and XE7 Firemonkey
can anybody tell me how to make a TTrackBar object read only in C++Builder (or Delphi) XE7 in an OSX firemonkey application? 有人可以告诉我如何在OSX firemonkey应用程序中使TTrackBar对象在C ++ Builder(或Delphi)XE7中只读吗? I tried the "Locked" property but it seems not working. 我尝试了“锁定”属性,但似乎无法正常工作。
Cheers 干杯
dodo 渡渡鸟
Set the Enabled
property to False
. 将Enabled
属性设置为False
。 Locked
locks the position of the trackbar in the designer so that you cannot accidentally move it. Locked
锁定跟踪器在设计器中的位置,这样就不会意外移动它。
Here's another answer because of your additional requirements. 由于您的其他要求,这是另一个答案。 There is no "readonly" property that will keep the TrackBar enabled. 没有任何“只读”属性可以使TrackBar保持启用状态。
You could just use the TrackBar.OnChange event and just reset the value if the user tries to change it: 您可以只使用TrackBar.OnChange事件,并在用户尝试更改值时重置该值:
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
TrackBar1.Value := 50;
end;
A more advanced approach is using an observer in order to get a true readonly TrackBar. 一种更高级的方法是使用观察器以获取真正的只读TrackBar。
TReadOnlyTrackObserver = class(TInterfacedObject, IEditLinkObserver, IObserver, ISingleCastObserver)
public
procedure Removed;
function GetActive: Boolean;
procedure SetActive(Value: Boolean);
function GetOnObserverToggle: TObserverToggleEvent;
procedure SetOnObserverToggle(AEvent: TObserverToggleEvent);
procedure Update;
function Edit: Boolean;
procedure Reset;
procedure Modified;
function IsModified: Boolean;
function IsValidChar(AKey: Char): Boolean;
function IsRequired: Boolean;
function GetIsReadOnly: Boolean;
procedure SetIsReadOnly(Value: Boolean);
property IsReadOnly: Boolean read GetIsReadOnly write SetIsReadOnly;
function GetIsEditing: Boolean;
property IsEditing: Boolean read GetIsEditing;
procedure BeginUpdate;
procedure EndUpdate;
function GetUpdating: Boolean;
property Updating: Boolean read GetUpdating;
end;
function TReadOnlyTrackObserver.GetActive: Boolean;
begin
Result := True;
end;
function TReadOnlyTrackObserver.GetIsReadOnly: Boolean;
begin
Result := True;
end;
// todo: implement the other required functions of TReadOnlyTrackObserver
var
MyObserver: IEditLinkObserver;
MyObserver := TReadOnlyTrackObserver.Create;
TrackBar1.Observers.AddObserver(TObserverMapping.EditLinkID, MyObserver);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.