* Use meta key for selection under MacOSX. Patch by Anton S.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1759 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2011-07-25 21:50:18 +00:00
parent 1dae858558
commit f387b1d170

View File

@ -474,6 +474,12 @@ const
UtilityImageSize = 16; // Needed by descendants for hittests. UtilityImageSize = 16; // Needed by descendants for hittests.
{$if defined(LCLCarbon) or defined(LCLCocoa)}
ssCtrlOS = ssMeta; // Mac OS X fix
{$else}
ssCtrlOS = ssCtrl;
{$endif}
var // Clipboard format IDs used in OLE drag'n drop and clipboard transfers. var // Clipboard format IDs used in OLE drag'n drop and clipboard transfers.
CF_VIRTUALTREE, CF_VIRTUALTREE,
CF_VTREFERENCE, CF_VTREFERENCE,
@ -9667,6 +9673,8 @@ begin
Result := []; Result := [];
if GetKeyState(VK_SHIFT) < 0 then if GetKeyState(VK_SHIFT) < 0 then
Include(Result, ssShift); Include(Result, ssShift);
if GetKeyState(VK_LWIN) < 0 then // Mac OS X substitute of ssCtrl
Include(Result, ssMeta);
if GetKeyState(VK_CONTROL) < 0 then if GetKeyState(VK_CONTROL) < 0 then
Include(Result, ssCtrl); Include(Result, ssCtrl);
if GetKeyState(VK_MENU) < 0 then if GetKeyState(VK_MENU) < 0 then
@ -11731,7 +11739,7 @@ begin
MaxY := Max(OldRect.Bottom, NewRect.Bottom); MaxY := Max(OldRect.Bottom, NewRect.Bottom);
// Initialize short hand variables to speed up tests below. // Initialize short hand variables to speed up tests below.
DoSwitch := ssCtrl in FDrawSelShiftState; DoSwitch := ssCtrlOS in FDrawSelShiftState;
WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages);
// Don't check the events here as descendant trees might have overriden the DoGetImageIndex method. // Don't check the events here as descendant trees might have overriden the DoGetImageIndex method.
WithImages := Assigned(FImages); WithImages := Assigned(FImages);
@ -11918,7 +11926,7 @@ begin
MaxY := Max(OldRect.Bottom, NewRect.Bottom); MaxY := Max(OldRect.Bottom, NewRect.Bottom);
// Initialize short hand variables to speed up tests below. // Initialize short hand variables to speed up tests below.
DoSwitch := ssCtrl in FDrawSelShiftState; DoSwitch := ssCtrlOS in FDrawSelShiftState;
WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages); WithCheck := (toCheckSupport in FOptions.FMiscOptions) and Assigned(FCheckImages);
// Don't check the events here as descendant trees might have overriden the DoGetImageIndex method. // Don't check the events here as descendant trees might have overriden the DoGetImageIndex method.
WithImages := Assigned(FImages); WithImages := Assigned(FImages);
@ -12788,7 +12796,7 @@ procedure TBaseVirtualTree.HandleClickSelection(LastFocused, NewNode: PVirtualNo
begin begin
// Ctrl key down // Ctrl key down
if ssCtrl in Shift then if ssCtrlOS in Shift then
begin begin
if ssShift in Shift then if ssShift in Shift then
begin begin
@ -15075,7 +15083,7 @@ begin
begin begin
{$ifdef DEBUG_VTV}Logger.Send([lcScroll],'Scroll Vertical - WheelDelta', WheelDelta);{$endif} {$ifdef DEBUG_VTV}Logger.Send([lcScroll],'Scroll Vertical - WheelDelta', WheelDelta);{$endif}
// Scroll vertically if there's something to scroll... // Scroll vertically if there's something to scroll...
if ssCtrl in State then if ssCtrlOS in State then
ScrollAmount := Trunc(WheelFactor * ClientHeight) ScrollAmount := Trunc(WheelFactor * ClientHeight)
else else
begin begin
@ -15095,7 +15103,7 @@ begin
else else
RTLFactor := 1; RTLFactor := 1;
if ssCtrl in State then if ssCtrlOS in State then
ScrollAmount := Trunc(WheelFactor * (ClientWidth - FHeader.Columns.GetVisibleFixedWidth)) ScrollAmount := Trunc(WheelFactor * (ClientWidth - FHeader.Columns.GetVisibleFixedWidth))
else else
begin begin
@ -15623,7 +15631,7 @@ begin
NewColumn := GetNextColumn(NewColumn); NewColumn := GetNextColumn(NewColumn);
if NewColumn > InvalidColumn then if NewColumn > InvalidColumn then
begin begin
if (Shift = [ssCtrl]) and not ActAsGrid then if (Shift = [ssCtrlOS]) and not ActAsGrid then
begin begin
ScrollIntoView(Node, toCenterScrollIntoView in FOptions.SelectionOptions, ScrollIntoView(Node, toCenterScrollIntoView in FOptions.SelectionOptions,
not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions)); not (toDisableAutoscrollOnFocus in FOptions.FAutoOptions));
@ -15634,7 +15642,7 @@ begin
end end
else else
begin begin
if not ActAsGrid or (ssCtrl in Shift) then if not ActAsGrid or (ssCtrlOS in Shift) then
FocusedNode := Node; FocusedNode := Node;
if ActAsGrid and not (toFullRowSelect in FOptions.FSelectionOptions) then if ActAsGrid and not (toFullRowSelect in FOptions.FSelectionOptions) then
FocusedColumn := NewColumn; FocusedColumn := NewColumn;
@ -15642,7 +15650,7 @@ begin
end; end;
end; end;
VK_PRIOR: VK_PRIOR:
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetY(FOffsetY + ClientHeight) SetOffsetY(FOffsetY + ClientHeight)
else else
begin begin
@ -15667,7 +15675,7 @@ begin
FocusedNode := Node; FocusedNode := Node;
end; end;
VK_NEXT: VK_NEXT:
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetY(FOffsetY - ClientHeight) SetOffsetY(FOffsetY - ClientHeight)
else else
begin begin
@ -15694,7 +15702,7 @@ begin
VK_UP: VK_UP:
begin begin
// scrolling without selection change // scrolling without selection change
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetY(FOffsetY + Integer(FDefaultNodeHeight)) SetOffsetY(FOffsetY + Integer(FDefaultNodeHeight))
else else
begin begin
@ -15721,7 +15729,7 @@ begin
VK_DOWN: VK_DOWN:
begin begin
// scrolling without selection change // scrolling without selection change
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetY(FOffsetY - Integer(FDefaultNodeHeight)) SetOffsetY(FOffsetY - Integer(FDefaultNodeHeight))
else else
begin begin
@ -15748,7 +15756,7 @@ begin
VK_LEFT: VK_LEFT:
begin begin
// special handling // special handling
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetX(FOffsetX + RTLFactor * FHeader.Columns.GetScrollWidth) SetOffsetX(FOffsetX + RTLFactor * FHeader.Columns.GetScrollWidth)
else else
begin begin
@ -15794,7 +15802,7 @@ begin
VK_RIGHT: VK_RIGHT:
begin begin
// special handling // special handling
if ssCtrl in Shift then if ssCtrlOS in Shift then
SetOffsetX(FOffsetX - RTLFactor * FHeader.Columns.GetScrollWidth) SetOffsetX(FOffsetX - RTLFactor * FHeader.Columns.GetScrollWidth)
else else
begin begin
@ -15944,7 +15952,7 @@ begin
VK_ADD: VK_ADD:
if not (tsIncrementalSearching in FStates) then if not (tsIncrementalSearching in FStates) then
begin begin
if ssCtrl in Shift then if ssCtrlOS in Shift then
if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then
FullExpand FullExpand
else else
@ -15958,7 +15966,7 @@ begin
VK_SUBTRACT: VK_SUBTRACT:
if not (tsIncrementalSearching in FStates) then if not (tsIncrementalSearching in FStates) then
begin begin
if ssCtrl in Shift then if ssCtrlOS in Shift then
if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then if {$ifdef ReverseFullExpandHotKey} not {$endif ReverseFullExpandHotKey} (ssShift in Shift) then
FullCollapse FullCollapse
else else
@ -16062,7 +16070,7 @@ begin
DoPopupMenu(FFocusedNode, FFocusedColumn, Point(R.Left + Offset div 2, (R.Top + R.Bottom) div 2)); DoPopupMenu(FFocusedNode, FFocusedColumn, Point(R.Left + Offset div 2, (R.Top + R.Bottom) div 2));
end; end;
Ord('a'), Ord('A'): Ord('a'), Ord('A'):
if ssCtrl in Shift then if ssCtrlOS in Shift then
SelectAll(True) SelectAll(True)
else else
DoStateChange([tsIncrementalSearchPending]); DoStateChange([tsIncrementalSearchPending]);
@ -16073,7 +16081,7 @@ begin
// of checking for valid characters for incremental search. // of checking for valid characters for incremental search.
// This is available but would require to include a significant amount of Unicode character // This is available but would require to include a significant amount of Unicode character
// properties, so we stick with the simple space check. // properties, so we stick with the simple space check.
if (Shift * [ssCtrl, ssAlt] = []) and (CharCode >= 32) then if (Shift * [ssCtrlOS, ssAlt] = []) and (CharCode >= 32) then
DoStateChange([tsIncrementalSearchPending]); DoStateChange([tsIncrementalSearchPending]);
end; end;
end; end;
@ -20888,7 +20896,7 @@ begin
NewNode := FFocusedNode <> HitInfo.HitNode; NewNode := FFocusedNode <> HitInfo.HitNode;
// Translate keys and filter out shift and control key. // Translate keys and filter out shift and control key.
ShiftState := KeysToShiftState(Message.Keys) * [ssShift, ssCtrl, ssAlt]; ShiftState := KeysToShiftState(Message.Keys) * [ssShift, ssCtrlOS, ssAlt];
if ssAlt in ShiftState then if ssAlt in ShiftState then
begin begin
AltPressed := True; AltPressed := True;
@ -23337,7 +23345,7 @@ begin
// consider modifier keys and what is allowed at the moment, if none of the following conditions apply then // consider modifier keys and what is allowed at the moment, if none of the following conditions apply then
// the initial value just set is used // the initial value just set is used
if ssCtrl in Shift then if ssCtrlOS in Shift then
begin begin
// copy or link // copy or link
if ssShift in Shift then if ssShift in Shift then
@ -30517,7 +30525,7 @@ begin
// If a multiline node is being edited the finish editing only if Ctrl+Enter was pressed, // If a multiline node is being edited the finish editing only if Ctrl+Enter was pressed,
// otherwise allow to insert line breaks into the text. // otherwise allow to insert line breaks into the text.
Shift := KeyDataToShiftState(Message.KeyData); Shift := KeyDataToShiftState(Message.KeyData);
EndEdit := ssCtrl in Shift; EndEdit := ssCtrlOS in Shift;
end; end;
if EndEdit then if EndEdit then
begin begin