- fix wrong use of TControl.Hint:
a) GetLongHint should be assigned to Application.Hint and updated on mouse control change
b) GetShortHint to HintWindow
- a bit of formatting

git-svn-id: trunk@14858 -
This commit is contained in:
paul 2008-04-17 08:26:34 +00:00
parent 9c888a7965
commit cbe1c50f78

View File

@ -150,8 +150,7 @@ begin
FreeThenNil(FIcon); FreeThenNil(FIcon);
FreeThenNil(FFormList); FreeThenNil(FFormList);
for HandlerType:=Low(TApplicationHandlerType) to High(TApplicationHandlerType) for HandlerType:=Low(TApplicationHandlerType) to High(TApplicationHandlerType) do
do
FreeThenNil(FApplicationHandlers[HandlerType]); FreeThenNil(FApplicationHandlers[HandlerType]);
UnregisterFindGlobalComponentProc(@FindApplicationComponent); UnregisterFindGlobalComponentProc(@FindApplicationComponent);
@ -366,9 +365,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TApplication.MouseIdle(const CurrentControl: TControl); procedure TApplication.MouseIdle(const CurrentControl: TControl);
begin begin
if FMouseControl <> CurrentControl then begin if FMouseControl <> CurrentControl then
UpdateMouseControl(CurrentControl); UpdateMouseControl(CurrentControl);
end;
end; end;
procedure TApplication.SetCaptureExceptions(const AValue: boolean); procedure TApplication.SetCaptureExceptions(const AValue: boolean);
@ -473,15 +471,27 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TApplication.UpdateMouseControl(NewMouseControl: TControl); procedure TApplication.UpdateMouseControl(NewMouseControl: TControl);
var
HintControl: TControl;
begin begin
//debugln(['TApplication.UpdateMouseControl Old=',DbgSName(FMouseControl),' New=',DbgSName(NewMouseControl)]); //debugln(['TApplication.UpdateMouseControl Old=',DbgSName(FMouseControl),' New=',DbgSName(NewMouseControl)]);
if FMouseControl=NewMouseControl then exit; if FMouseControl = NewMouseControl then
if (FMouseControl<>nil) then begin Exit;
if (FMouseControl <> nil) then
begin
//DebugLn' MOUSELEAVE=',FMouseControl.Name,':',FMouseControl.ClassName); //DebugLn' MOUSELEAVE=',FMouseControl.Name,':',FMouseControl.ClassName);
FMouseControl.Perform(CM_MOUSELEAVE, 0, 0); FMouseControl.Perform(CM_MOUSELEAVE, 0, 0);
end; end;
FMouseControl := NewMouseControl; FMouseControl := NewMouseControl;
if (FMouseControl<>nil) then begin
HintControl := GetHintControl(FMouseControl);
if HintControl = nil then
Application.Hint := ''
else
Application.Hint := GetLongHint(HintControl.Hint);
if (FMouseControl <> nil) then
begin
//DebugLn' MOUSEENTER=',FMouseControl.Name,':',FMouseControl.ClassName); //DebugLn' MOUSEENTER=',FMouseControl.Name,':',FMouseControl.ClassName);
FMouseControl.Perform(CM_MOUSEENTER, 0, 0); FMouseControl.Perform(CM_MOUSEENTER, 0, 0);
end; end;
@ -647,8 +657,6 @@ begin
debugln('TApplication.ShowHintWindow A OldHint="',Hint,'" NewHint="',GetShortHint(Info.Control.Hint),'"'); debugln('TApplication.ShowHintWindow A OldHint="',Hint,'" NewHint="',GetShortHint(Info.Control.Hint),'"');
{$endif} {$endif}
Hint := GetShortHint(Info.Control.Hint);
CurHeight:=GetCursorHeightMargin; CurHeight:=GetCursorHeightMargin;
HintInfo.HintControl := FHintControl; HintInfo.HintControl := FHintControl;
HintInfo.HintPos := Info.MousePos; HintInfo.HintPos := Info.MousePos;
@ -669,7 +677,7 @@ begin
OffsetRect(HintInfo.CursorRect, ParentOrigin.X - ClientOrigin.X, OffsetRect(HintInfo.CursorRect, ParentOrigin.X - ClientOrigin.X,
ParentOrigin.Y - ClientOrigin.Y); ParentOrigin.Y - ClientOrigin.Y);
HintInfo.CursorPos := FHintControl.ScreenToClient(Info.MousePos); HintInfo.CursorPos := FHintControl.ScreenToClient(Info.MousePos);
HintInfo.HintStr := Hint; HintInfo.HintStr := GetShortHint(Info.Control.Hint);
HintInfo.ReshowTimeout := 0; HintInfo.ReshowTimeout := 0;
HintInfo.HideTimeout := FHintHidePause HintInfo.HideTimeout := FHintHidePause
+FHintHidePausePerChar*length(HintInfo.HintStr); +FHintHidePausePerChar*length(HintInfo.HintStr);
@ -1043,12 +1051,7 @@ begin
if FHintTimer<>nil then FHintTimer.Enabled:=false; if FHintTimer<>nil then FHintTimer.Enabled:=false;
HideHint; HideHint;
if FHintControl <> nil then if FHintControl <> nil then
begin
FHintControl := nil; FHintControl := nil;
//FHintActive := False;
//UnhookHintHooks;
//StopHintTimer;
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1122,23 +1125,20 @@ begin
end; end;
end; end;
function TApplication.DispatchAction(Msg: Longint; Action: TBasicAction function TApplication.DispatchAction(Msg: Longint; Action: TBasicAction): Boolean;
): Boolean;
var var
Form: TCustomForm; Form: TCustomForm;
begin begin
Result:=false; Result := False;
Form := Screen.ActiveForm; Form := Screen.ActiveForm;
if (Form<>nil) and (Form.Perform(Msg, 0, PtrInt(Action)) = 1) then if (Form <> nil) and (Form.Perform(Msg, 0, PtrInt(Action)) = 1) then
Result:=true Result := True
else if (MainForm<>Form) and (MainForm<>nil) else
and (MainForm.Perform(Msg, 0, PtrInt(Action)) = 1) if (MainForm <> Form) and (MainForm <> nil) and (MainForm.Perform(Msg, 0, PtrInt(Action)) = 1) then
then Result := True;
Result:=true;
// Disable action if no "user" handler is available // Disable action if no "user" handler is available
if (not Result) and (Action is TCustomAction) if (not Result) and (Action is TCustomAction) and
and TCustomAction(Action).Enabled TCustomAction(Action).Enabled and TCustomAction(Action).DisableIfNoHandler then
and TCustomAction(Action).DisableIfNoHandler then
TCustomAction(Action).Enabled := Assigned(Action.OnExecute); TCustomAction(Action).Enabled := Assigned(Action.OnExecute);
end; end;
@ -1164,14 +1164,18 @@ end;
procedure TApplication.SetHint(const AValue: string); procedure TApplication.SetHint(const AValue: string);
begin begin
if FHint=AValue then exit; if FHint = AValue then
FHint:=AValue; Exit;
if Assigned(FOnHint) or (FApplicationHandlers[ahtHint].Count>0) then begin FHint := AValue;
if Assigned(FOnHint) or (FApplicationHandlers[ahtHint].Count > 0) then
begin
FOnHint(Self); FOnHint(Self);
FApplicationHandlers[ahtHint].CallNotifyEvents(Self); FApplicationHandlers[ahtHint].CallNotifyEvents(Self);
end else begin end else
begin
// Send THintAction // Send THintAction
with TCustomHintAction.Create(Self) do begin with TCustomHintAction.Create(Self) do
begin
Hint := FHint; Hint := FHint;
try try
Execute; Execute;