mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 05:49:30 +02:00
LCL Carbon: fixed #0011835: TScrollBox scrolling TMemo in carbon
- fixed #0011831: TComboBox csDropDown on carbon git-svn-id: trunk@16158 -
This commit is contained in:
parent
c1dd4c638e
commit
0c41e61467
@ -578,7 +578,7 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCarbonWidget.BoundsChanged
|
||||
Method: TCarbonWidget.ControlAdded
|
||||
|
||||
Notifies about control added
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -35,7 +35,7 @@ uses
|
||||
MacOSAll,
|
||||
{$endif}
|
||||
// LCL
|
||||
LMessages, LCLMessageGlue, LCLProc, LCLType, Graphics, Controls, StdCtrls,
|
||||
LMessages, LCLMessageGlue, LCLProc, LCLType, Graphics, Controls, StdCtrls, ExtCtrls,
|
||||
Spin,
|
||||
// widgetset
|
||||
WSControls, WSLCLClasses, WSProc,
|
||||
@ -78,6 +78,10 @@ type
|
||||
FItemIndex: Integer;
|
||||
FReadOnly: Boolean;
|
||||
FPopupMenu: MenuRef;
|
||||
FTimer: TTimer;
|
||||
FLastDroppedDown: Boolean;
|
||||
procedure DropDownTimer(Sender: TObject);
|
||||
// there is no drop down nor close up event in Carbon, we must check it with timer
|
||||
protected
|
||||
procedure RegisterEvents; override;
|
||||
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||
@ -90,6 +94,7 @@ type
|
||||
procedure ValueChanged; override;
|
||||
procedure FocusSet; override;
|
||||
procedure FocusKilled; override;
|
||||
procedure TextDidChange; override;
|
||||
public
|
||||
function GetText(var S: String): Boolean; override;
|
||||
function SetBounds(const ARect: TRect): Boolean; override;
|
||||
@ -102,6 +107,7 @@ type
|
||||
procedure Remove(AIndex: Integer);
|
||||
|
||||
function DropDown(ADropDown: Boolean): Boolean;
|
||||
function IsDroppedDown: Boolean;
|
||||
end;
|
||||
|
||||
{ TCarbonCustomEdit }
|
||||
@ -520,6 +526,55 @@ begin
|
||||
(AWidget as TCarbonComboBox).ListItemSelected(Index);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: CarbonComboBox_MenuOpening
|
||||
Handles combo box menu open event
|
||||
------------------------------------------------------------------------------}
|
||||
function CarbonComboBox_MenuOpening(ANextHandler: EventHandlerCallRef;
|
||||
AEvent: EventRef;
|
||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||
begin
|
||||
{$IFDEF VerboseControlEvent}
|
||||
DebugLn('CarbonComboBox_MenuOpening: ', DbgSName(AWidget.LCLObject));
|
||||
{$ENDIF}
|
||||
|
||||
Result := CallNextEventHandler(ANextHandler, AEvent);
|
||||
|
||||
LCLSendDropDownMsg(AWidget.LCLObject);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: CarbonComboBox_MenuClosed
|
||||
Handles combo box menu closed event
|
||||
------------------------------------------------------------------------------}
|
||||
function CarbonComboBox_MenuClosed(ANextHandler: EventHandlerCallRef;
|
||||
AEvent: EventRef;
|
||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||
begin
|
||||
{$IFDEF VerboseControlEvent}
|
||||
DebugLn('CarbonComboBox_MenuClosed: ', DbgSName(AWidget.LCLObject));
|
||||
{$ENDIF}
|
||||
|
||||
Result := CallNextEventHandler(ANextHandler, AEvent);
|
||||
|
||||
LCLSendCloseUpMsg(AWidget.LCLObject);
|
||||
end;
|
||||
|
||||
procedure TCarbonComboBox.DropDownTimer(Sender: TObject);
|
||||
var
|
||||
D: Boolean;
|
||||
begin
|
||||
D := IsDroppedDown;
|
||||
if D <> FLastDroppedDown then
|
||||
begin
|
||||
FLastDroppedDown := D;
|
||||
if FLastDroppedDown then
|
||||
LCLSendDropDownMsg(LCLObject)
|
||||
else
|
||||
LCLSendCloseUpMsg(LCLObject);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCarbonComboBox.RegisterEvents
|
||||
|
||||
@ -546,8 +601,10 @@ end;
|
||||
procedure TCarbonComboBox.CreateWidget(const AParams: TCreateParams);
|
||||
var
|
||||
CFString: CFStringRef;
|
||||
TmpSpec: EventTypeSpec;
|
||||
begin
|
||||
FReadOnly := (LCLObject as TCustomComboBox).ReadOnly;
|
||||
FLastDroppedDown := False;
|
||||
|
||||
if FReadOnly then
|
||||
begin
|
||||
@ -559,6 +616,16 @@ begin
|
||||
|
||||
OSError(CreateNewMenu(0, kMenuAttrAutoDisable, FPopupMenu),
|
||||
Self, SCreateWidget, 'CreateNewMenu');
|
||||
|
||||
TmpSpec := MakeEventSpec(kEventClassMenu, kEventMenuOpening);
|
||||
InstallMenuEventHandler(FPopupMenu,
|
||||
RegisterEventHandler(@CarbonComboBox_MenuOpening),
|
||||
1, @TmpSpec, Pointer(Self), nil);
|
||||
|
||||
TmpSpec := MakeEventSpec(kEventClassMenu, kEventMenuClosed);
|
||||
InstallMenuEventHandler(FPopupMenu,
|
||||
RegisterEventHandler(@CarbonComboBox_MenuClosed),
|
||||
1, @TmpSpec, Pointer(Self), nil);
|
||||
|
||||
OSError(
|
||||
SetControlData(ControlRef(Widget), kControlEntireControl,
|
||||
@ -579,6 +646,11 @@ begin
|
||||
finally
|
||||
FreeCFString(CFString);
|
||||
end;
|
||||
|
||||
FreeAndNil(FTimer);
|
||||
FTimer := TTimer.Create(LCLObject);
|
||||
FTimer.Interval := 200;
|
||||
FTimer.OnTimer := @DropDownTimer;
|
||||
end;
|
||||
|
||||
FItemIndex := -1;
|
||||
@ -662,7 +734,7 @@ procedure TCarbonComboBox.FocusSet;
|
||||
begin
|
||||
inherited;
|
||||
// emulate DropDown event here
|
||||
LCLSendDropDownMsg(LCLObject);
|
||||
//LCLSendDropDownMsg(LCLObject);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -674,7 +746,20 @@ procedure TCarbonComboBox.FocusKilled;
|
||||
begin
|
||||
inherited;
|
||||
// emulate CloseUp event here
|
||||
LCLSendCloseUpMsg(LCLObject);
|
||||
//LCLSendCloseUpMsg(LCLObject);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCarbonComboBox.TextDidChange
|
||||
|
||||
Text changed event handler
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCarbonComboBox.TextDidChange;
|
||||
begin
|
||||
inherited TextDidChange;
|
||||
|
||||
// TComboBox needs LM_CHANGED message type
|
||||
SendSimpleMessage(LCLObject, LM_CHANGED);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -844,6 +929,11 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TCarbonComboBox.IsDroppedDown: Boolean;
|
||||
begin
|
||||
Result := HIComboBoxIsListVisible(ControlRef(Widget));
|
||||
end;
|
||||
|
||||
{ TCarbonCustomEdit }
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -798,6 +798,7 @@ end;
|
||||
procedure TCarbonCustomControl.ScrollTo(const ANewOrigin: HIPoint);
|
||||
var
|
||||
ScrollMsg: TLMScroll;
|
||||
I: Integer;
|
||||
begin
|
||||
{$IFDEF VerboseScroll}
|
||||
DebugLn('TCarbonCustomControl.ScrollTo ' + LCLObject.Name + ' Origin: ' +
|
||||
@ -831,6 +832,16 @@ begin
|
||||
end;
|
||||
DeliverMessage(LCLObject, ScrollMsg);
|
||||
|
||||
// force update all child views - BUG in OS X
|
||||
for I := 0 to LCLObject.ControlCount - 1 do
|
||||
if (LCLObject.Controls[I] is TWinControl) and
|
||||
(LCLObject.Controls[I] as TWinControl).HandleAllocated and
|
||||
TCarbonWidget((LCLObject.Controls[I] as TWinControl).Handle).IsVisible then
|
||||
begin
|
||||
TCarbonWidget((LCLObject.Controls[I] as TWinControl).Handle).ShowHide(False);
|
||||
TCarbonWidget((LCLObject.Controls[I] as TWinControl).Handle).ShowHide(True);
|
||||
end;
|
||||
|
||||
// scroll bars can change client rect - update it
|
||||
UpdateLCLClientRect;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user