OnClick and MouseDown not working when using 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.

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.

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.

Here is complete code :

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;


There is a one trick with this to "check" if the eq. TButton with a DragMode=TDragMode.dmAutomatic. Simply check the time distance between OnMouseLeave and OnMouseEnter... The code:

uses DateUtils; var Time1:TDateTime; procedure TForm4.Button2MouseLeave(Sender: TObject); begin Memo1.Lines.Add('OnMouseLeave'); Time1:=Now; end; procedure TForm4.Button2MouseEnter(Sender: TObject); var A:Integer; begin A:=MillisecondsBetween(Time1,Now); Memo1.Lines.Add('OnMouseEnter '+IntToStr(A)); end;

Then see that with clicking the TButton the time distance is always 0. Another events results with a larger time distance.

I know that it's a not clear approach to solve this problem, but Embarcadero sometimes makes me berserk...


  • ORM, DataBinding to DataGridView: inserting/deleted new rows not saved to the database
  • Getting “Error: EACCES, mkdir” whenever I try to install something with bower
  • Can't start running a local Grails app
  • .apk installed on Android but cannot be found anywhere!
  • How to get the previous day records from mysql table?
  • No persistence units parsed from {classpath*:META-INF/persistence.xml}
  • Secure Asset/Media Folder through Auth Controller ? Laravel 5.2
  • fast way to remove lowercase substrings from string?
  • NSMutableURLRequest and redirection
  • AnyHashable:Any doesn't convert to dictionary in swift when receives through push notification
  • PostgreSQL manualy change query execution plan to force using sort and sequential access instead of
  • How to marry NioServerSocketChannelFactory and WorkManager
  • How to use Twitter gem in Rails, need small to figure out the whole thing?
  • pip installation of gmpy2
  • Incompatible block pointer types SDWebImage
  • Contact us email sending is not working in codeigniter php
  • How do you save a Linq object if you don't have its data context?
  • Starting Bootstrap tour with a button after ending tour once
  • Extract the data specified in brackets '[ ]' from a string message in python
  • Linking with 32bit libraries under linux 64bit
  • Office.js mail object properties missing in TypeScript
  • in Gwt, there are 2 different packages (or 2 options) for doing drag n Drop? Which one is better?
  • Bulk loading into PostgreSQL from a remote client
  • Move elements from a listbox to another
  • Opening tel: links from UIWebView
  • How to display youtube video on HTML page? [closed]
  • Admob in ListView not clickable
  • Unable to start a WebView from an AsyncTask
  • time column in sqlite using gorm
  • How to use Streams api peek() function and make it work?
  • Terminal run dalvikvm with am.jar
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Why isn't stemDocument stemming?
  • How to decleare char *const argv[] in swift [duplicate]
  • How to handle div that is created dynamically in a table
  • Google App Engine backend servlet not responding
  • How to get rgb from transparent pixel in js
  • Make checkout phone field optional for specific countries in WooCommerce
  • WPF custom control and direct content support
  • ReferenceError: TextEncoder is not defined