不要onmousedown事件和OnMouseUp只能作为对工作的? [英] Do OnMouseDown and OnMouseUp only work as a pair?

查看:198
本文介绍了不要onmousedown事件和OnMouseUp只能作为对工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有很多TRectangle的演技的键盘按键的。当点击一个你听到声音。这是通过处理onmousedown事件和OnMouseUp事件完成。 onmousedown事件:发送声音和OnMouseUp:将其关闭。一切工作正常,除了一件事。

My application has a lot of TRectangle's acting as keys of a keyboard. When one is clicked you hear a sound. This is done by handling the OnMouseDown and OnMouseUp event. OnMouseDown: send a sound and OnMouseUp: switch it off. All works fine, except for one thing.

在Android上我可以用几个手指preSS几个键。当一个onmousedown事件已被处理,没有其他的onmousedown事件事件将被处理,直到OnMouseUp事件已处理。它不必是关键的是阻止其他onmousedown事件的OnMouseUp,它可以是任何OnMouseUp事件。示例code:

On Android I can use several fingers to press several keys. When one OnMouseDown has been processed, no other OnMouseDown Events will be processed until an OnMouseUp event has been processed. It needn't be the OnMouseUp of the key that blocked the other OnMouseDown, it may be any OnMouseUp event. Sample code:

procedure TKeyBoard.note_down (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
   key: TKey;
begin
   key := Sender as TKey;
   logd ('Entering OnMouseDown event handler: %d', [key.Note]);
   PutShort ($90, key.Note, 127);
   logd ('Exiting OnMouseDown event handler: %d', [key.Note]);
end; // note_down //

procedure TKeyBoard.note_up (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
   key: TKey;
begin
   key := Sender as TKey;
   logd ('Entering OnMouseUp event handler: %d', [key.Note]);
   PutShort ($80, Key.Note, 127);
   logd ('Exiting OnMouseUp event handler: %d', [key.Note]);
end; // note_up //
...
Rectangle [i].OnMouseDown := note_down;
Rectangle [i].OnMouseUp   := note_up;

凡note_down和note_up例程进入和退出立即根据调试code。那么,是否可以认为,直到OnMouseUp已处理,当一个onmousedown事件已处理完毕,没有onmousedown事件的可处理?如果是这样,有没有解决办法?

Where the note_down and note_up routines are entered and exited immediately according to the debug code. Is it right to assume that when an OnMouseDown has been processed, no OnMouseDown's can be processed until an OnMouseUp has been handled? If so, is there a workaround?

推荐答案

使OnMouseEnter在移动出手了。我工作的一个项目,有很多矩形的,在我的code我有

Give OnMouseEnter a shot for mobile. I'm working on a project with lots of rectangles and in my code I have

{$ifdef MSWINDOWS}
lRect.OnClick := ClickEvent;
{$else}
lRect.OnMouseEnter := ClickEvent;
{$endif}

这是什么可以让我做的是拖动整个矩形网格我的手指,并把它叫我ClickEvent每个矩形我传了过来。

What this allows me to do is drag my finger across a grid of rectangles and have it call my ClickEvent for each rectangle I pass over.

这篇关于不要onmousedown事件和OnMouseUp只能作为对工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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