Polaris 1 Posted June 19, 2014 (edited) I'm basically trying to monitor the position of the mouse and move a control using the positional updates (in effect dragging the control with the mouse). I'm trying to create the ability to drag from a listnbox to a slot and have the display name or picture follow the mouse. Preferably I'd be using onLBDragging but that stops reporting as soon as you drag outside its control's area (not very useful since I can't see a way to extend the control's area without destroying its styling and creating large unpopulated columns). I can't use onMouseMoving with a control (allowing me to use direct X and Y) because the listnbox is the focus (therefore the EH simply doesn't fire if the lnb is being used). So I'm trying to use onMouseMoving with the display and it's fairly accurate but I can't seem to make it perfect for some reason, it's simply a little inaccurate, lagging slightly behind or in front, etc and the inaccuracy grows the further you drag it. I was hoping someone may have experimented with this before and may have some suggestions. Also if anyone has any ideas of a different (better) way to do it please feel free! (findDisplay 7001) displayAddEventHandler ["MouseMoving", "[_this, ctrlPosition ((findDisplay 7001) displayCtrl 2043)] call DraggingUpdate"]; DraggingUpdate = { _curPos = _this select 0; _position = _this select 1; ((findDisplay 7001) displayCtrl 2043) ctrlSetPosition [(_position select 0) + (((_curPos select 1) / 100)), (_position select 1) + (((_curPos select 2) / 100))]; ((findDisplay 7001) displayCtrl 2043) ctrlCommit 0; }; Edited June 19, 2014 by Polaris Share this post Link to post Share on other sites
Polaris 1 Posted June 20, 2014 I'm reasonably sure that the BISimulations wiki is actually correct and onMouseMoving actually returns mouse speed rather than the delta X and Y as stated by the BIS wiki. But I'm also pretty sure that mouse speed and delta X and Y aren't transferable which is why the above code isn't working perfectly. "For displays or non-compatible controls the display and mouse speed x,y is returned" Share this post Link to post Share on other sites
Larrow 2822 Posted June 20, 2014 I'm reasonably sure that the BISimulations wiki is actually correct and onMouseMoving actually returns mouse speed rather than the delta X and Y as stated by the BIS wiki. Im not so sure on this, a while back i spent quite a bit of time trying to get something similar to work.If you set something like this up and play in window mode and as quickly as you can move your mouse across the instance of ARMA then both x and y read around 100, seems to be a percentage of screen distance covered in a frame. I found that if you divide this percentage by safezoneW or H then its pretty much spot on. You still get a little drift but it was the closest i could get. I was under the impression that this very slight drift was due to maybe missing a few mouse updates and that each frame is not quite enough? ((findDisplay 7001) displayCtrl 2043) ctrlSetPosition [(_position select 0) + (((_curPos select 1) / 100) / safeZoneW), (_position select 1) + (((_curPos select 2) / 100) / safeZoneH)]; Very interested to hear if you find something stable Polaris Share this post Link to post Share on other sites
Polaris 1 Posted June 20, 2014 (edited) That's interesting, I stumbled on the 100 by accident while playing around with the values. I found that adding the safeZoneW/H division actually made it less accurate and it lagged further behind mouse movements. Try lowering your mouse sensitivity and seeing what effect it has. For me it has a huge impact on the onMouseMoving values. That's why I was leaning towards the BISimulations wiki being correct (also the "some kind of x and y delta position" doesn't really sound like it was an official addition to the wiki whereas the BISimulations one does). Plus there shouldn't really be any missed mouse movements because as soon as the EH reports I assume it resets practically instantly and if you make sure every EH that's fired is used then that really shouldn't be an issue. It'd be really nice if BIS simply told us exactly what value was being given and how to convert it accurately to actual delta X and Y (actually what would be ideal is if onMouseMoving reported the actual X and Y which would be infinitely more useful). Edit: I was trying to experiment with having a screen sized control and using the real X and Y reported from that but...you run into the focus issue again. I may try creating a separate dialog with the screen sized control and see if creating a child dialog with the lnb allows the control to still report the mouse position while having the focus on the lnb. Also note that if you change your mouse sensitivity the cursor moves at the same speed regardless BUT the X and Y reported by onMouseMoving change significantly! Meaning even if you were to create the perfect manipulation of the values so the control moved perfectly with the cursor, it would probably still change depending on the user's mouse settings. So, realising that, I may attempt to find a solution that doesn't involve onMouseMoving with a display (my only current idea is the one I posted above) unless someone can post a method of using the values that works regardless of the user's settings (*cough* BIS *cough*). Edited June 20, 2014 by Polaris Share this post Link to post Share on other sites
Polaris 1 Posted June 21, 2014 (edited) onLBDragging stops reporting when moved outside of its control BUT one of the values it reports is the IDC of the control it's currently hovering over...so it seems like this is a bug? http://feedback.arma3.com/view.php?id=19309 Edit: LBDrag and LBDrop function perfectly already so if LBDragging worked properly the whole issue would be sorted. Edited June 21, 2014 by Polaris Share this post Link to post Share on other sites
Polaris 1 Posted June 23, 2014 Ah ok, basically the lack of documentation was the issue (once again). Use the LB/LNB event handlers for this to be perfectly accurate. Share this post Link to post Share on other sites
Larrow 2822 Posted June 23, 2014 Try lowering your mouse sensitivity and seeing what effect it has. For me it has a huge impact on the onMouseMoving values. Ah ok i see what your talking about. My values where so close that it led me to believe i was close and must have been dropping precision somewhere. Thank god as the formula was not quite making sense.. I would have expected to multiply percentage moved via safezone not divided.Spent sometime looking through the config's to see if there are any mouse sensitivity values, found everything but, graphics, joystick etc are all there, shame profileNamespace doesnt seem to include the actual base profile as you could do profileNamespace getVariable "MouseSensativityX" but seems limited to the VARS file only. It'd be really nice if BIS simply told us exactly what value was being given and how to convert it accurately to actual delta X and Y (actually what would be ideal is if onMouseMoving reported the actual X and Y which would be infinitely more useful).Wouldn't it just, not holding my breath.onLBDragging stops reporting when moved outside of its control BUT one of the values it reports is the IDC of the control it's currently hovering over...so it seems like this is a bug? Mmm ok, doesnt really help me as im not necessarily using LB's but was looking for a way to report drag and drop from multiple types of ctrls...Thinking out loud here, if it stops reporting x,y but does tell you the current control could you not monitor the idc and add a ctrl event to it using mousemoving. In essence a floating event that attaches itself to what ever control your over?? Although the WIKI does say the mouseMoving for a ctrl returns the x,y relative to the control so maybe some maths need to get it to act properly. Ah ok, basically the lack of documentation was the issue (once again). Use the LB/LNB event handlers for this to be perfectly accurate. ? Have you got an example, im a little confused, I thought you said above that it doesnt report the position once outside the LB. Share this post Link to post Share on other sites
Polaris 1 Posted June 25, 2014 (edited) I'm using the listbox event handlers because they suit my exact needs, even if they are a serious pain to get working properly. I have discovered a way of using onMouseMoving though which might be of interest to you if you want a non-listbox method. Essentially you need to... Create a control (probably a button with full transparency and the size of the area you want the user to be able to drag in) with onMouseMoving AND onMouseHolding assigned to it (referred to as MouseMoving control). Assign onMouseButtonDown to whatever control you want to drag (referred to as ButtonDown control). Then in the ButtonDown handler code you need to set focus to the MouseMoving control (allowing the handlers assigned to it to fire) and then in the MouseMoving/Holding handler code you need to set the position of the drag control to the X and Y reported by onMouseMoving and onMouseHolding and then optionally shift focus back to the drag control once it's been dropped (onMouseButtonUp). This method will NOT work with the listbox handlers though, but should work with any others. Edited June 25, 2014 by Polaris Share this post Link to post Share on other sites
Larrow 2822 Posted June 25, 2014 Ok thanks The invisible cover all ctrl is the first way i tried and even with set focus i was still experiencing focusing/z ordering issues that is why i turned to the display event instead. I will have to have another look at this. Thanks again Polaris Share this post Link to post Share on other sites
Polaris 1 Posted June 25, 2014 You could also probably have it as the foremost control and then simply disable it when it's not in use so it doesn't interfere with anything else but I haven't tried that. Share this post Link to post Share on other sites