mouse

004-行为型-09-访问者模式(Visitor)

依然范特西╮ 提交于 2019-11-30 09:38:13
一、概述   它分离对象的数据和行为,使用Visitor模式,可以不修改已有类的情况下,增加新的操作。    主要解决: 稳定的数据结构和易变的操作耦合问题。    注意事项: 访问者可以对功能进行统一,可以做报表、UI、拦截器与过滤器。 1.1、适用场景   1、对象结构中对象对应的类很少改变,但经常需要在此对象结构上定义新的操作。   2、需要对一个对象结构中的对象进行很多不同的并且不相关的操作,而需要避免让这些操作"污染"这些对象的类,也不希望在增加新操作时修改这些类。 1.2、优缺点   优点: 1、符合单一职责原则。 2、优秀的扩展性。 3、灵活性。   缺点: 1、具体元素对访问者公布细节,违反了迪米特原则。 2、具体元素变更比较困难。 3、违反了依赖倒置原则,依赖了具体类,没有依赖抽象。 1.3、类图角色及其职责      访问者模式的角色和职责    1、 访问者角色(Visitor): 为该对象结构中具体元素角色声明一个访问操作接口。该操作接口的名字和参数标识了发送访问请求给具体访问者的具体元素角色。这样访问者就可以通过该元素角色的特定接口直接访问它。    2、具体访问者角色(Concrete Visitor): 实现每个由访问者角色(Visitor)声明的操作。    3、元素角色(Element): 定义一个Accept操作,它以一个访问者为参数。    4

How to scroll WPF ScrollViewer's content to specific location

拈花ヽ惹草 提交于 2019-11-30 07:53:29
问题 I am writing my custom WPF ItemsControl to display a list of item. The items are shown embedded inside a ScrollViewer: <Style TargetType="MyCustomItemsControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="MyCustomItemsControl"> <ScrollViewer x:Name="PART_MyScrollViewer" > <ItemsPresenter/> </ScrollViewer> </ControlTemplate> </Setter.Value> </Setter> </Style> I want to make sure that when I move the mouse into the control, a particular item (marked as selected)

How to programatically trigger a mouse left click in C#?

好久不见. 提交于 2019-11-30 07:39:53
How could I programmatically trigger a left-click event on the mouse? Thanks. edit: the event is not triggered directly on a button. I'm aiming for the Windows platform. AlexanderMP https://web.archive.org/web/20140214230712/http://www.pinvoke.net/default.aspx/user32.sendinput Use the Win32 API to send input. Update: Since I no longer work with Win32 API, I will not update this answer to be correct when the platform changes or websites become unavailable. Since this answer doesn't even conform to Stackoverflow standards (does not contain the answer itself, but rather a link to an external, now

Simulating a mouse button click in Windows

僤鯓⒐⒋嵵緔 提交于 2019-11-30 07:39:37
问题 I'm writing Remote Desktop clone in C++ using QT. So far I'm able to move the mouse cursor around fine. QT has a nice setPos function for that. However, I'm a bit lost as to what API/Library to use for simulating mouse button clicks. One method I'm aware of is to send the WM_(event) to a window using the window's HWND. However, I was hoping there was a more salient method for taking complete control over a mouse. Is there any other way to tell the operating system that the left mouse button

Detect both left and right mouse click at the same time?

家住魔仙堡 提交于 2019-11-30 07:33:23
问题 I'm remaking windows Minesweeper (from XP) and something they had included was that if you click a number with as many flags as it's number with the left and right mouse button at the same time, it reveals every other hidden tile around that number. I'm having a hard time telling when both the Left and Right mouse buttons are pressed at the exact same time... I'm using a pair of bools, one for each button with the OnMouseDown and OnMouseUp events but if the 2 buttons are clicked at the exact

How can I detect a held down mouse button over a PictureBox?

纵然是瞬间 提交于 2019-11-30 06:57:21
I need to fire an event when the mouse is above a PictureBox with the mouse button already clicked and held down. Problems: The MouseDown and MouseEnter event handlers do not work together very well. For instance once a mouse button is clicked and held down, C# will fire the MouseDown event handler, but when the cursor moves over the PictureBox the MouseEnter event does not fire, until the mouse button is realeased. When the mouse is pressed down most controls will then Control.Capture the mouse input. This means that all MouseMove events are sent to the original control that captured rather

How to read low level mouse click position in linux .

馋奶兔 提交于 2019-11-30 05:03:55
I am using this code to read mouse events from the dev/input/event* in linux . #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/input.h> #include <fcntl.h> #define MOUSEFILE "/dev/input/event4" int main() { int fd; struct input_event ie; if((fd = open(MOUSEFILE, O_RDONLY)) == -1) { perror("opening device"); exit(EXIT_FAILURE); } while(read(fd, &ie, sizeof(struct input_event))) { printf("time %ld.%06ld\ttype %d\tcode %d\tvalue %d\n", ie.time.tv_sec, ie.time.tv_usec, ie.type, ie.code, ie.value); } return 0; } It gives me the results in the format : time 1342517261

Emacs, unicode, xterm mouse escape sequences, and wide terminals

牧云@^-^@ 提交于 2019-11-30 05:00:49
Short version: When using emacs' xterm-mouse-mode, Somebody (emacs? bash? xterm?) intercepts xterm's control sequences and replaces them with \0. This is a pain on wide monitors because only the first 223 columns have mouse. What is the culprit, and how can I work around it? From what I can tell this has something to do with Unicode/UTF-8 support, because it wasn't a problem 5-6 years ago when I last had a big monitor. Gory details follow... Thanks! Emacs xterm-mouse-mode has a well-known weakness handling mouse clicks starting around x=95. A workaround , adopted by recent versions of emacs,

Java : ignore single click on double click?

两盒软妹~` 提交于 2019-11-30 04:54:23
can anyone think of a good way to ignore the single click that comes with a double-click in Java ? I'm looking to have different behaviors for each such that: single-click paints crosshairs on the click point double-click selects an object on the screen, but should not paint crosshairs on the click point ... can anyone think of a way to do this ? Some sort of timer set-up maybe ? An ideas appreciated :-) <disclaimer> ...and yes, I know I'm committing a most heinous usability / UI faux pas. </disclaimer> EDIT #2: Even though this works the delay due to the timer is maddening - I'm abandoning

How to disable mouse right click on a web page? [duplicate]

廉价感情. 提交于 2019-11-30 04:49:33
This question already has an answer here: How do I disable right click on my web page? 23 answers I want to disable mouse right click on an HTML page. I have a page where user has to enter the details. I don't want the user to see the menu thats get displayed with the mouse right click. Rather I want to display a custom menu. I know there are some plugins available to do that. But my requirement does not need any plugins. It's unprofessional, anyway this will work with javascript enabled: document.oncontextmenu = document.body.oncontextmenu = function() {return false;} You may also want to