![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Re^2: Unable to capture mouse events in Win32::Consoleby fireblood (Scribe) |
on Apr 26, 2022 at 03:50 UTC ( [id://11143297]=note: print w/replies, xml ) | Need Help?? |
Hi Anonymous, thanks for replying so quickly. Actually, I had seen that sample code previously, and had downloaded and run it, and found that although it displayed amazing graphics, it too did not respond to my mouse clicks. I also noticed that it did not have a $console -> Alloc () instruction anywhere, which I initially thought might be why neither it nor my program responded to mouse events, because I did not have a $console -> Alloc either. However, when I added a $console -> Alloc () instruction to my code, the window in which my program was running would instantly vanish as soon as the $console -> Alloc instruction was reached. So I fiddled with $console -> Free () with it for a while, to no avail, and finally removed the $console -> Alloc instruction again. I have now revised my code to eliminate the 1-second sleep. By commenting one instruction or not, I can make it sleep only a hundredth of a second or not sleep at all, with the results being the same, viz. no mouse events are detected. This is the revised code:
When I run this revised version and press any key, the following is generated:
But as before, I can click on the mouse all night, and this is what is generated:
I've thought about re-writing my application in Win32::GUI but it would involve writing a lot more code creating and managing the window entirely within the program, not just hooking into a pre-existing console as with Win32::Console.
In Section
Seekers of Perl Wisdom
|
|