mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
Merged revision(s) 62561-62562 #c6feb9685a-#c6feb9685a, 62568 #6758ea533d, 62589 #edd505d679, 62661-62663 #cdede4ea6f-#cdede4ea6f from trunk:
cocoa: assigning callback to a spinedits arrows ........ cocoa: getting rid of unnecessary text change notifications. bug #36578 ........ cocoa: surpressing beeps on windows for unknown key presses ........ cocoa: eliminating horizontal spacing between columns to match winapi. bug #36618 ........ cocoa: adding automatic largeInc determination based of the page size ........ cocoa: removing additional offset on large scroll ........ cocoa: passing scroll part information, whenever the scroll part is known ........ git-svn-id: branches/fixes_2_0@62666 -
This commit is contained in:
parent
8c392f47f1
commit
374c0f7699
@ -91,7 +91,7 @@ type
|
||||
procedure DidResignKeyNotification;
|
||||
procedure SendOnChange;
|
||||
procedure SendOnTextChanged;
|
||||
procedure scroll(isVert: Boolean; Pos: Integer);
|
||||
procedure scroll(isVert: Boolean; Pos: Integer; AScrollPart: NSScrollerPart = NSScrollerNoPart);
|
||||
// non event methods
|
||||
function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult;
|
||||
function GetPropStorage: TStringList;
|
||||
|
@ -183,10 +183,22 @@ var
|
||||
begin
|
||||
Result := false;
|
||||
case prt of
|
||||
NSScrollerDecrementPage: adj := -sc.largeInc;
|
||||
NSScrollerIncrementPage: adj := sc.largeInc;
|
||||
NSScrollerDecrementLine: adj := -sc.smallInc;
|
||||
NSScrollerIncrementLine: adj := sc.smallInc;
|
||||
NSScrollerDecrementPage: begin
|
||||
adj := -sc.largeInc;
|
||||
if adj = 0 then adj := -sc.pageInt;
|
||||
end;
|
||||
NSScrollerIncrementPage: begin
|
||||
adj := sc.largeInc;
|
||||
if adj = 0 then adj := sc.pageInt;
|
||||
end;
|
||||
NSScrollerDecrementLine: begin
|
||||
adj := -sc.smallInc;
|
||||
if adj = 0 then adj := -1;
|
||||
end;
|
||||
NSScrollerIncrementLine: begin
|
||||
adj := sc.smallInc;
|
||||
if adj = 0 then adj := 1;
|
||||
end;
|
||||
else
|
||||
adj := 0;
|
||||
end;
|
||||
@ -818,7 +830,7 @@ begin
|
||||
HandleMouseDown(self, locInWin, prt);
|
||||
|
||||
if Assigned(callback) then
|
||||
callback.scroll( not IsHorizontal(), lclPos);
|
||||
callback.scroll(not IsHorizontal(), lclPos, prt);
|
||||
end;
|
||||
|
||||
function TCocoaScrollBar.IsHorizontal: Boolean;
|
||||
|
@ -395,10 +395,13 @@ type
|
||||
procedure scrollWheel(event: NSEvent); override;
|
||||
end;
|
||||
|
||||
TCocoaSpinEdit = objcclass(TCocoaTextField, NSTextFieldDelegateProtocol)
|
||||
TCocoaSpinEdit = objcclass(TCocoaTextField)
|
||||
Stepper: NSStepper;
|
||||
NumberFormatter: NSNumberFormatter;
|
||||
decimalPlaces: Integer;
|
||||
|
||||
avoidChangeEvent: Integer;
|
||||
|
||||
//Spin: TCustomFloatSpinEdit;
|
||||
procedure dealloc; override;
|
||||
function updateStepper: boolean; message 'updateStepper';
|
||||
@ -408,9 +411,6 @@ type
|
||||
procedure PositionSubcontrols(const ALeft, ATop, AWidth, AHeight: Integer); message 'PositionSubcontrols:ATop:AWidth:AHeight:';
|
||||
procedure StepperChanged(sender: NSObject); message 'StepperChanged:';
|
||||
procedure textDidChange(notification: NSNotification); override;
|
||||
procedure textDidEndEditing(notification: NSNotification); message 'textDidEndEditing:'; override;
|
||||
// NSTextFieldDelegateProtocol
|
||||
procedure controlTextDidChange(obj: NSNotification); override;
|
||||
// lcl
|
||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||
function lclGetCallback: ICommonCallback; override;
|
||||
@ -1953,9 +1953,6 @@ begin
|
||||
Stepper.setTarget(Self);
|
||||
Stepper.setAction(objcselector('StepperChanged:'));
|
||||
|
||||
// Accept numbers only
|
||||
setDelegate(Self);
|
||||
|
||||
{ The default way to do this in Cocoa is with NSNumberFormatter
|
||||
But it is a bit annoying, it just disallows losing focus from the control
|
||||
instead of the Windows like solution to just override with the last value
|
||||
@ -2011,27 +2008,20 @@ begin
|
||||
setStringValue(lNSStr);
|
||||
lNSStr.release;
|
||||
// This implements OnChange for both user and code changes
|
||||
if callback <> nil then callback.SendOnTextChanged();
|
||||
if (callback <> nil) and (avoidChangeEvent=0) then
|
||||
callback.SendOnTextChanged();
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.textDidChange(notification: NSNotification);
|
||||
begin
|
||||
updateStepper;
|
||||
inherited textDidChange(notification);
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.textDidEndEditing(notification: NSNotification);
|
||||
begin
|
||||
updateStepper;
|
||||
StepperChanged(nil); // and refresh self
|
||||
inherited textDidEndEditing(notification);
|
||||
//if Assigned(callback) then callback.SendOnTextChanged;
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.controlTextDidChange(obj: NSNotification);
|
||||
begin
|
||||
updateStepper;
|
||||
if Assigned(callback) then callback.SendOnTextChanged;
|
||||
inc(avoidChangeEvent);
|
||||
try
|
||||
updateStepper;
|
||||
StepperChanged(nil); // and refresh self
|
||||
inherited textDidChange(notification);
|
||||
finally
|
||||
dec(avoidChangeEvent);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCocoaSpinEdit.acceptsFirstResponder: LCLObjCBoolean;
|
||||
|
@ -143,6 +143,7 @@ type
|
||||
_keyEvCallback: ICommonCallback;
|
||||
callback: IWindowCallback;
|
||||
keepWinLevel : NSInteger;
|
||||
stopKeyEquivalent: Boolean;
|
||||
//LCLForm: TCustomForm;
|
||||
procedure dealloc; override;
|
||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||
@ -168,6 +169,7 @@ type
|
||||
procedure sendEvent(event: NSEvent); override;
|
||||
// key
|
||||
procedure keyDown(event: NSEvent); override;
|
||||
function performKeyEquivalent(event: NSEvent): LCLObjCBoolean; override;
|
||||
// menu support
|
||||
procedure lclItemSelected(sender: id); message 'lclItemSelected:';
|
||||
|
||||
@ -989,7 +991,18 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// we tried everything (all keyEquiovalents), see calls above
|
||||
// now we just want to stop the Beep
|
||||
stopKeyEquivalent:=true;
|
||||
inherited keyDown(event);
|
||||
stopKeyEquivalent:=false;
|
||||
end;
|
||||
|
||||
function TCocoaWindow.performKeyEquivalent(event: NSEvent): LCLObjCBoolean;
|
||||
begin
|
||||
Result:=inherited performKeyEquivalent(event);
|
||||
if stopKeyEquivalent and not Result then
|
||||
Result := true;
|
||||
end;
|
||||
|
||||
function TCocoaWindowContentDocument.draggingEntered(sender: NSDraggingInfoProtocol): NSDragOperation;
|
||||
|
@ -993,6 +993,7 @@ var
|
||||
lTableLV: TCocoaTableListView;
|
||||
ns: NSRect;
|
||||
lclcb: TLCLListViewCallback;
|
||||
sz: NSSize;
|
||||
begin
|
||||
{$IFDEF COCOA_DEBUG_LISTVIEW}
|
||||
WriteLn('[TCocoaWSCustomListView.CreateHandle] AWinControl='+IntToStr(PtrInt(AWinControl)));
|
||||
@ -1030,6 +1031,10 @@ begin
|
||||
ScrollViewSetBorderStyle(lCocoaLV, TCustomListView(AWinControl).BorderStyle);
|
||||
UpdateFocusRing(lTableLV, TCustomListView(AWinControl).BorderStyle);
|
||||
|
||||
sz := lTableLV.intercellSpacing;
|
||||
// Windows compatibility. on Windows there's no extra space between columns
|
||||
sz.width := 0;
|
||||
lTableLV.setIntercellSpacing(sz);;
|
||||
{$IFDEF COCOA_DEBUG_LISTVIEW}
|
||||
WriteLn(Format('[TCocoaWSCustomListView.CreateHandle] headerView=%d', [PtrInt(lTableLV.headerView)]));
|
||||
{$ENDIF}
|
||||
|
@ -92,7 +92,7 @@ type
|
||||
procedure DidResignKeyNotification; virtual;
|
||||
procedure SendOnChange; virtual;
|
||||
procedure SendOnTextChanged; virtual; // text controls (like spin) respond to OnChange for this event, but not for SendOnChange
|
||||
procedure scroll(isVert: Boolean; Pos: Integer); virtual;
|
||||
procedure scroll(isVert: Boolean; Pos: Integer; AScrollPart: NSScrollerPart); virtual;
|
||||
function DeliverMessage(var Msg): LRESULT; virtual; overload;
|
||||
function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; virtual; overload;
|
||||
procedure Draw(ControlContext: NSGraphicsContext; const bounds, dirty: NSRect); virtual;
|
||||
@ -1329,10 +1329,12 @@ begin
|
||||
SendSimpleMessage(Target, CM_TEXTCHANGED);
|
||||
end;
|
||||
|
||||
procedure TLCLCommonCallback.scroll(isVert: Boolean; Pos: Integer);
|
||||
procedure TLCLCommonCallback.scroll(isVert: Boolean; Pos: Integer;
|
||||
AScrollPart: NSScrollerPart);
|
||||
var
|
||||
LMScroll: TLMScroll;
|
||||
b: Boolean;
|
||||
lclCode: Integer;
|
||||
begin
|
||||
FillChar(LMScroll{%H-}, SizeOf(LMScroll), #0);
|
||||
//todo: this should be a part of a parameter
|
||||
@ -1344,7 +1346,15 @@ begin
|
||||
LMScroll.Msg := LM_HSCROLL;
|
||||
|
||||
LMScroll.Pos := Pos;
|
||||
LMScroll.ScrollCode := SB_THUMBPOSITION; //SIF_POS;
|
||||
case AScrollPart of
|
||||
NSScrollerDecrementPage: lclCode := SB_PAGELEFT;
|
||||
NSScrollerIncrementPage: lclCode := SB_PAGERIGHT;
|
||||
NSScrollerDecrementLine: lclCode := SB_LINELEFT;
|
||||
NSScrollerIncrementLine: lclCode := SB_LINERIGHT;
|
||||
else
|
||||
lclCode := SB_THUMBPOSITION;
|
||||
end;
|
||||
LMScroll.ScrollCode := lclCode; //SIF_POS;
|
||||
|
||||
LCLMessageGlue.DeliverMessage(Target, LMScroll);
|
||||
end;
|
||||
|
@ -69,6 +69,8 @@ begin
|
||||
lSpin.decimalPlaces := -1;
|
||||
lSpin.lclCreateSubcontrols(AParams);
|
||||
lSpin.callback := TLCLCommonCallback.Create(lSpin, AWinControl);
|
||||
if (lSpin.Stepper.isKindOfClass(TCocoaSpinEditStepper)) then
|
||||
TCocoaSpinEditStepper(lSpin.Stepper).callback:=lSpin.callback;
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomFloatSpinEdit.DestroyHandle(const AWinControl: TWinControl);
|
||||
|
Loading…
Reference in New Issue
Block a user