April 29, 201214 yr Commercial Member I'm trying to detect two mouse buttons selected at the same time: if((mouse_flags & MOUSE_RIGHTSINGLE) && (mouse_flags & MOUSE_MIDDLESINGLE)) - but it never triggers. The MOUSE_CHILD_FUNCT listing is correct: (...)MOUSE_LEFTSINGLE | MOUSE_RIGHTSINGLE | MOUSE_DOWN_REPEAT | MOUSE_MIDDLESINGLE, ap_ias_select_mcb So, a simple question - what has eejit here overlooked? -Dai
April 29, 201214 yr Dai, You're dealing with a callback function, so the value of the mouse_flags variable is a reflection of action, not state. Declare a couple of variables: BOOL bLeftButton, bMiddleButton; Then use if statements, similar to the one you have, to determine the current position of each button. Once the position of each button has been determined, you can then take action as required. Doug
May 1, 201214 yr Author Commercial Member Thanks Doug - that definately fixed the immediate problem. I don't really need an answer to the following in that I've figured out a way around it, but do you know if it's possible to inject directly into a mouse callback e.g. if I had a variable set then that variable will keep calling the mouse callback until the variable is unset? -Dai
May 1, 201214 yr Not sure what you're trying to achieve here. Are you trying to increase the rate at which the function is called, or are you trying to prevent the function from being called? Neither is really possible. You can invoke the callback function as often as you like from within your own code, but then you would have to deal with setting the bits within the mouse_flags variable. Not terribly useful, unless you have independently retrieved state information from the mouse. If you're looking to limit calls to the callback function, the only way to do so is to deregister the callback function. This approach would likely be a PITA compared to simply using a global variable and an if statement to limit what the callback function actually does when it is called. Doug
May 3, 201214 yr Author Commercial Member I've taken the easy way out and rather than try to keep poking the mouse callback function to read the button state, I've assigned global variables to all of the mouse buttons and I'm dealing with the resulting required actions in the gauge callback - which led to a very unexpected result when using the information to rotate a control. I had assumed that the mouse callback was polled at tick18 intervals but I've just been very rudely informed by FS that it's not so. In comparison to rotating controls in the mouse callback, the same code in the gauge callback has them turning on steroids.... :shok:. I'm about to wrap that part of the code in a tick18 clock to slow the actions down again. All this because in the mouse callback, if I selected (say) the left button for one action, then selected both buttons to change the action, releasing the right button did not return to the initial left button action. It is as if the initial button action has 'expired'. -Dai
Create an account or sign in to comment