TStringGrid-不调用OnMouseUp! [英] TStringGrid - OnMouseUp is not called!
问题描述
我在Delphi 7中使用TStringGrid有一个怪异的行为。如果弹出菜单与网格关联,则
Delphi不会调用OnMouseUp事件。基本上,当按下RMB时,菜单的弹出会以某种方式取消/延迟OnMouseUp。实际上,为了达到100%的准确度,下次您按下鼠标按钮时,会两次调用OnMouseUp,一次是针对当前事件,一次是针对丢失/延迟的事件。
这将破坏程序的整个逻辑,因为下次用户按下鼠标按钮时将调用不需要的代码。
我已经采用了某种与Sertac描述的方法类似的方法:我只是不再使用PopupMenu属性为网格分配弹出菜单。相反,在我的网格(我的网格是从TStringGrid派生而来的经过修改的字符串网格)内部,我处理了鼠标按下事件并以所需的方式显示弹出窗口,并在菜单弹出之前进行了我想做的额外处理。 p>
I have a weird behavior with TStringGrid in Delphi 7. Delphi does not call the OnMouseUp event if a pop-up menu is associated to the grid. Basically, when the RMB is pressed, the pop of the menu somehow cancels/delays the OnMouseUp. Actually, to be 100% accurate, next time you push a mouse button the OnMouseUp is called twice – once for the current event, and once for the lost/delayed event.
This will screwup the entire logic of the program as unwanted code will be called next time when the user presses a mouse button.
I already took an approach somehow similar with the one described by Sertac: I just don't use the PopupMenu property anymore to assign a pop-up menu to the grid. Instead, inside my grid (my grid is a heavily modified string grid derived from TStringGrid) I handle the mouse down event and display the pop-up the way I want AND do the extra processing I wanted to do BEFORE the menu pops.
这篇关于TStringGrid-不调用OnMouseUp!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!