mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:19:19 +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;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonWidget.BoundsChanged
|
Method: TCarbonWidget.ControlAdded
|
||||||
|
|
||||||
Notifies about control added
|
Notifies about control added
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
@ -35,7 +35,7 @@ uses
|
|||||||
MacOSAll,
|
MacOSAll,
|
||||||
{$endif}
|
{$endif}
|
||||||
// LCL
|
// LCL
|
||||||
LMessages, LCLMessageGlue, LCLProc, LCLType, Graphics, Controls, StdCtrls,
|
LMessages, LCLMessageGlue, LCLProc, LCLType, Graphics, Controls, StdCtrls, ExtCtrls,
|
||||||
Spin,
|
Spin,
|
||||||
// widgetset
|
// widgetset
|
||||||
WSControls, WSLCLClasses, WSProc,
|
WSControls, WSLCLClasses, WSProc,
|
||||||
@ -78,6 +78,10 @@ type
|
|||||||
FItemIndex: Integer;
|
FItemIndex: Integer;
|
||||||
FReadOnly: Boolean;
|
FReadOnly: Boolean;
|
||||||
FPopupMenu: MenuRef;
|
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
|
protected
|
||||||
procedure RegisterEvents; override;
|
procedure RegisterEvents; override;
|
||||||
procedure CreateWidget(const AParams: TCreateParams); override;
|
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||||
@ -90,6 +94,7 @@ type
|
|||||||
procedure ValueChanged; override;
|
procedure ValueChanged; override;
|
||||||
procedure FocusSet; override;
|
procedure FocusSet; override;
|
||||||
procedure FocusKilled; override;
|
procedure FocusKilled; override;
|
||||||
|
procedure TextDidChange; override;
|
||||||
public
|
public
|
||||||
function GetText(var S: String): Boolean; override;
|
function GetText(var S: String): Boolean; override;
|
||||||
function SetBounds(const ARect: TRect): Boolean; override;
|
function SetBounds(const ARect: TRect): Boolean; override;
|
||||||
@ -102,6 +107,7 @@ type
|
|||||||
procedure Remove(AIndex: Integer);
|
procedure Remove(AIndex: Integer);
|
||||||
|
|
||||||
function DropDown(ADropDown: Boolean): Boolean;
|
function DropDown(ADropDown: Boolean): Boolean;
|
||||||
|
function IsDroppedDown: Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonCustomEdit }
|
{ TCarbonCustomEdit }
|
||||||
@ -520,6 +526,55 @@ begin
|
|||||||
(AWidget as TCarbonComboBox).ListItemSelected(Index);
|
(AWidget as TCarbonComboBox).ListItemSelected(Index);
|
||||||
end;
|
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
|
Method: TCarbonComboBox.RegisterEvents
|
||||||
|
|
||||||
@ -546,8 +601,10 @@ end;
|
|||||||
procedure TCarbonComboBox.CreateWidget(const AParams: TCreateParams);
|
procedure TCarbonComboBox.CreateWidget(const AParams: TCreateParams);
|
||||||
var
|
var
|
||||||
CFString: CFStringRef;
|
CFString: CFStringRef;
|
||||||
|
TmpSpec: EventTypeSpec;
|
||||||
begin
|
begin
|
||||||
FReadOnly := (LCLObject as TCustomComboBox).ReadOnly;
|
FReadOnly := (LCLObject as TCustomComboBox).ReadOnly;
|
||||||
|
FLastDroppedDown := False;
|
||||||
|
|
||||||
if FReadOnly then
|
if FReadOnly then
|
||||||
begin
|
begin
|
||||||
@ -560,6 +617,16 @@ begin
|
|||||||
OSError(CreateNewMenu(0, kMenuAttrAutoDisable, FPopupMenu),
|
OSError(CreateNewMenu(0, kMenuAttrAutoDisable, FPopupMenu),
|
||||||
Self, SCreateWidget, 'CreateNewMenu');
|
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(
|
OSError(
|
||||||
SetControlData(ControlRef(Widget), kControlEntireControl,
|
SetControlData(ControlRef(Widget), kControlEntireControl,
|
||||||
kControlPopupButtonOwnedMenuRefTag, SizeOf(MenuRef), @FPopupMenu),
|
kControlPopupButtonOwnedMenuRefTag, SizeOf(MenuRef), @FPopupMenu),
|
||||||
@ -579,6 +646,11 @@ begin
|
|||||||
finally
|
finally
|
||||||
FreeCFString(CFString);
|
FreeCFString(CFString);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
FreeAndNil(FTimer);
|
||||||
|
FTimer := TTimer.Create(LCLObject);
|
||||||
|
FTimer.Interval := 200;
|
||||||
|
FTimer.OnTimer := @DropDownTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FItemIndex := -1;
|
FItemIndex := -1;
|
||||||
@ -662,7 +734,7 @@ procedure TCarbonComboBox.FocusSet;
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
// emulate DropDown event here
|
// emulate DropDown event here
|
||||||
LCLSendDropDownMsg(LCLObject);
|
//LCLSendDropDownMsg(LCLObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -674,7 +746,20 @@ procedure TCarbonComboBox.FocusKilled;
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
// emulate CloseUp event here
|
// 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;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -844,6 +929,11 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCarbonComboBox.IsDroppedDown: Boolean;
|
||||||
|
begin
|
||||||
|
Result := HIComboBoxIsListVisible(ControlRef(Widget));
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCarbonCustomEdit }
|
{ TCarbonCustomEdit }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -798,6 +798,7 @@ end;
|
|||||||
procedure TCarbonCustomControl.ScrollTo(const ANewOrigin: HIPoint);
|
procedure TCarbonCustomControl.ScrollTo(const ANewOrigin: HIPoint);
|
||||||
var
|
var
|
||||||
ScrollMsg: TLMScroll;
|
ScrollMsg: TLMScroll;
|
||||||
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseScroll}
|
{$IFDEF VerboseScroll}
|
||||||
DebugLn('TCarbonCustomControl.ScrollTo ' + LCLObject.Name + ' Origin: ' +
|
DebugLn('TCarbonCustomControl.ScrollTo ' + LCLObject.Name + ' Origin: ' +
|
||||||
@ -831,6 +832,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
DeliverMessage(LCLObject, ScrollMsg);
|
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
|
// scroll bars can change client rect - update it
|
||||||
UpdateLCLClientRect;
|
UpdateLCLClientRect;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user