使用DragMode = dmAutomatic时,OnClick和MouseDown不起作用 [英] OnClick and MouseDown not working when using DragMode=dmAutomatic

查看:139
本文介绍了使用DragMode = dmAutomatic时,OnClick和MouseDown不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在左键单击TPanel和TAdvPanel(TMS组件)时也遇到问题。如果我设置 DragMode = dmAutomatic ,则单击鼠标左键不起作用。

I have a problem with left click on TPanel and TAdvPanel (TMS Components) also. If I set DragMode = dmAutomatic then Left click doesn't work. Right click works.

procedure TMain_Form.Panel_Item_01MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
   begin
     { whatever I type here nothing happen, even showmessage wont popup - no effect}
   end;
if Button = mbRight then
   begin
     { here code works fine }
   end;
end;

对我来说似乎很简单,但是...找不到解决此问题的方法,单击鼠标左键的呼叫过程。伙计们,有什么主意吗?

It seems simple to me but ... can't found the way how to resolve this issue and call procedure on left button click. Guys, any idea?

推荐答案

猜猜问题现在已解决。

Guess problem is resolved now.

如果将TPanel组件DragMode设置为dmAutomatic,则似乎无法触发OnClick事件。但是,当我将相同的TPanel DragMode设置为dmManual时,它甚至可以运行OnClick。

If you set TPanel component DragMode to dmAutomatic seems it can't trigger the OnClick event. However, when I set same TPanel DragMode to dmManual it can run OnClick even.

即使在我手动设置Panel_Item_01.DragMode:= dmManual;的情况下,也几乎不需要OnMouseEnter就能解决问题。现在它可以识别鼠标左键并保留TPanel DragDrop功能。

Problem solved with little help of OnMouseEnter even where I manually set Panel_Item_01.DragMode := dmManual; Now it can recognize left mouse button and preserve TPanel DragDrop functionality.

这是完整的代码:

procedure TMain_Form.Panel_Item_01MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
 if Button = mbLeft then
    begin
     Panel_Item_01.DragMode := dmManual;    
     { ..rest of code.. }  
    end;
 if Button = mbRight then
    begin
     Panel_Item_01.DragMode := dmAutomatic;
     { ..rest of code.. }  
    end;
end;

procedure TMain_Form.Panel_Item_01MouseEnter(Sender: TObject);
begin
 Panel_Item_01.DragMode := dmManual;
end;

procedure TMain_Form.Panel_Item_01MouseLeave(Sender: TObject);
begin
 Panel_Item_01.DragMode := dmAutomatic;
end;

这篇关于使用DragMode = dmAutomatic时,OnClick和MouseDown不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆