{"id":4425,"date":"2017-02-03T14:51:18","date_gmt":"2017-02-03T06:51:18","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4425"},"modified":"2017-02-03T15:00:00","modified_gmt":"2017-02-03T07:00:00","slug":"fmx%e5%bc%80%e5%b9%b4%e7%ac%ac%e4%b8%80%e5%bc%b9%ef%bc%9a%e4%bf%ae%e6%94%b9-fmx-controls-%e9%81%bf%e5%85%8d%e6%8c%89%e4%bd%8f%e7%bc%96%e8%be%91%e6%a1%86%e7%a7%bb%e5%8a%a8%e6%97%b6%e5%bc%b9%e5%87%ba","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4425","title":{"rendered":"[FMX]\u5f00\u5e74\u7b2c\u4e00\u5f39\uff1a\u4fee\u6539 FMX.Controls \u907f\u514d\u6309\u4f4f\u7f16\u8f91\u6846\u79fb\u52a8\u65f6\u5f39\u51fa\u8f93\u5165\u6cd5\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u5728 FMX \u4e2d\uff0c\u5f53\u7528\u6237\u5728\u7f16\u8f91\u6846\u4e0a\u6309\u4e0b\u65f6\uff0c\u8bb8\u591a\u573a\u666f\u4e0b\uff0c\u662f\u8981\u62d6\u52a8\u4f4d\u7f6e\uff0c\u4f46\u662f\uff0cFMX.Controls \u5728 MouseDown \u4e8b\u4ef6\u4e2d\uff0c\u5c31\u8c03\u7528\u4e86\u63a7\u4ef6\u7684 SetFocus \uff0c\u7ed3\u679c\u5c31\u9020\u6210\u6309\u4e0b\u65f6\uff0c\u5f39\u51fa\u8f93\u5165\u6cd5\uff0c\u5f71\u54cd\u62d6\u52a8\u64cd\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u76f8\u5e94\u7684\u4ee3\u7801\u90a3\u5230 MouseUp \u4e2d\u6765\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u3002\u540c\u65f6\uff0c\u6211\u4eec\u52a0\u4e00\u4e2a\u5224\u65ad\uff0c\u4ee5\u907f\u514d\u5c06\u62d6\u52a8\u8bc6\u522b\u4e3a\u70b9\u51fb\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u8981\u505a\u7684\u7b2c\u4e00\u6b65\u662f\u6253\u5f00 FMX.Controls.pas\uff0c\u627e\u5230\u4e0b\u9762\u7684\u8fd9\u6bb5\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">procedure TControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);\r\nbegin\r\n  if (not (csDesigning in ComponentState)) and (not FIsFocused) then\r\n    SetFocus;\r\n\r\n  if Assigned(FOnMouseDown) then\r\n    FOnMouseDown(Self, Button, Shift, X, Y);\r\n  if FAutoCapture then\r\n    Capture;\r\n  if (ssDouble in Shift) then\r\n  begin\r\n    DblClick;\r\n    FDoubleClick := True;\r\n  end\r\n  else if Button = TMouseButton.mbLeft then\r\n  begin\r\n    FPressed := True;\r\n    FPressedPosition := TPointF.Create(X, Y);\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\nend;seButton.mbLeft then\r\n  begin\r\n    FPressed := True;\r\n    FPressedPosition := TPointF.Create(X, Y);\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\nend;<\/pre>\n<p>\u5c06\u7b2c\u4e00\u53e5\u5220\u9664\uff0c\u4ee5\u907f\u514d\u5b83\u8bbe\u7f6e\u7126\u70b9\uff0c\u4fee\u6b63\u6210\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);\r\nbegin\r\n  if Assigned(FOnMouseDown) then\r\n    FOnMouseDown(Self, Button, Shift, X, Y);\r\n  if FAutoCapture then\r\n    Capture;\r\n  if (ssDouble in Shift) then\r\n  begin\r\n    DblClick;\r\n    FDoubleClick := True;\r\n  end\r\n  else if Button = TMouseButton.mbLeft then\r\n  begin\r\n    FPressed := True;\r\n    FPressedPosition := TPointF.Create(X, Y);\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\nend;seButton.mbLeft then\r\n  begin\r\n    FPressed := True;\r\n    FPressedPosition := TPointF.Create(X, Y);\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\nend;<\/pre>\n<p>\u7136\u540e\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230 TControl.MouseUp \u7684\u4ee3\u7801\uff08\u539f\u59cb\uff09\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TControl.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);\r\nbegin\r\n  ReleaseCapture;\r\n\r\n  if Assigned(FOnMouseUp) then\r\n    FOnMouseUp(Self, Button, Shift, X, Y);\r\n  if FPressed then\r\n  begin\r\n    FPressed := False;\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\n  FDoubleClick := False;\r\nend;<\/pre>\n<p>\u6211\u4eec\u8981\u4fee\u6539\u4e0b\u5b83\uff0c\u4ee5\u5728\u7528\u6237\u677e\u5f00\u65f6\uff0c\u5c06\u5982\u679c\u7528\u6237\u662f\u70b9\u51fb\u5728\u76f8\u5e94\u7684\u6309\u94ae\uff08\u79fb\u52a8\u8ddd\u79bb\u5c0f\u4e8e10\uff0c\u8fd9\u4e2a\u9600\u503c\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u8c03\u8282\uff0c\u4e00\u822c\u4e3a5-10\uff09\uff0c\u5219\u8bbe\u7f6e\u7126\u70b9\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TControl.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);\r\nbegin\r\n  if (not (csDesigning in ComponentState)) and (not FIsFocused) and (FPressedPosition.Distance(PointF(X,Y))&lt;10) then\r\n    SetFocus;\r\n  ReleaseCapture;\r\n\r\n  if Assigned(FOnMouseUp) then\r\n    FOnMouseUp(Self, Button, Shift, X, Y);\r\n  if FPressed then\r\n  begin\r\n    FPressed := False;\r\n    StartTriggerAnimation(Self, 'Pressed');\r\n  end;\r\n  FDoubleClick := False;\r\nend;<\/pre>\n<p>\u597d\u4e86\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u5c06\u4fee\u6539\u540e\u7684\u6e90\u7801\u590d\u5236\u5230\u4f60\u5de5\u7a0b\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u7528\u6765\u66ff\u6362\u7cfb\u7edf\u81ea\u5e26\u7684FMX.Controls\u3002<\/p>\n<p>\u5b9e\u9645\u8fd0\u884c\u6548\u679c\u89c6\u9891\uff1a<\/p>\n<div style=\"width: 768px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4425-1\" width=\"768\" height=\"432\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2017\/02\/SVID_20170203_145140_1.mp4?_=1\" \/><a href=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2017\/02\/SVID_20170203_145140_1.mp4\">https:\/\/blog.qdac.cc\/wp-content\/uploads\/2017\/02\/SVID_20170203_145140_1.mp4<\/a><\/video><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 FMX \u4e2d\uff0c\u5f53\u7528\u6237\u5728\u7f16\u8f91\u6846\u4e0a\u6309\u4e0b\u65f6\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[145,69,8,603],"tags":[149,629,704,705,544],"class_list":["post-4425","post","type-post","status-publish","format-standard","hentry","category-android","category-c-builder","category-delphi","category-603","tag-fmx","tag-629","tag-704","tag-705","tag-544"],"views":5374,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4425"}],"version-history":[{"count":3,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4425\/revisions"}],"predecessor-version":[{"id":4429,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4425\/revisions\/4429"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}