Multiple input.event triggers on single button press caused by Mouse or Gamepad Joystick movement in Godot 3.2.3 - input

I'm building a game in Godot and I am running into an issue where Input.is_action_pressed, Input.is_action_just_pressed, and Input.is_action_just_released are all triggering multiple times if the mouse or gamepad joysticks are moving while clicking the buttons. I have tried checking for is_echo, but nothing registers as an echo.
I am looking for input via:
func _input(event):
if Input.is_action_just_released("AttackRange"):
fireGun()
This is very easily repeatable for me right now. All I have to do is move my mouse around while clicking, or moving either of the joysticks on the gamepad while pressing buttons. I can't figure out what is causing this. Should I be listening for inputs in a different way?
Help would be greatly appreciated!

Yeah, you are mixing ways to get input.
Either use _input and process only the input you get in the event parameter. This is usually better for pointing input (mouse or touch).
Or put your code in _process (or _physics_process if necessary) and use the Input object.
In this particular case, I'd move the code you have to _process.

Related

Native caret position macos cocoa

I want to be able to get the global caret position inside any application in Mac High Sierra using cocoa or appleScript. I already use NSEvent to get the keyboard and mouse hook but is there a way to get the caret position hook?
The caret is different from the mouse position. It moves on key event or mouse click. In windows, you can get the caret position almost anywhere. I want to know if there is the equivalent for macos.
I want to show a popup over the text caret, if i type on the keyboard or line return, it moves with the text.I tried getting the position of the key event, (locationInWindow) but it give me back the mouse position. I am not sandbox so i can even call applescripts
UPDATE : It is possible doing this by getting the bounds of the letter before the caret with the use of accessibility API.
thanks
I don't have the opportunity to try it for myself just yet, so you might beat me to the punch of confirm/reject this.
UIEvent has addGlobalMonitorForEventsMatchingMask:handler: where the mask can have a value of NSEventMaskCursorUpdate and presumably the returned NSEvent object will contain a coordinate that can be acted upon (i.e. converted to screen-space).
Caveat here is the docs explicitly say
Key-related events may only be monitored if accessibility is enabled
or if your application is trusted for accessibility access (see
AXIsProcessTrusted).
Your post seems to suggest that you do not wish to use Accessibility API ("but if not using accessibility API") so that may mean you're out of luck in the specific combination of requirements you seek to fulfill.

CreateJS pressup/click won't trigger when target movie is played on mousedown/pressmove

I have a project where I need to make flash movie as an interactive game. Because, flash is already (or soon will be) obsolete for most of browsers, I've decided this game must be based on HTML5/JS. Because most of the graphics and animations are already done in this Flash movie (and I have its source), I'm developing it using Adobe Flash and CreateJS technology (HTML5 + Canvas + JS). So far, I like this solution pretty much, though I have an issue which I could not solve yet.
The game is a simple drag&drop matching game. The problem I have is shortly described in the question title and I will try to explain it here more detailed:
label.on('mousedown', function() {
//this.image.bg.gotoAndStop(2);
});
label.on('pressmove', function(evt) {
this.x = getStageX(evt.stageX);
this.y = getStageY(evt.stageY);
currentStage.setChildIndex(this, currentStage.getNumChildren() - 1);
stage.update();
});
label.on('pressup', function(evt) {
console.log('Hi! I'm mouseup event!')
this.x = labelInitX;
this.y = labelInitY;
this.image.bg.gotoAndStop(0);
});
Above, you can see simplified 3 event handlers I use. Everything is working fine until I uncomment second line - //this.image.bg.gotoAndStop(2);. When I do this, the pressup event does not trigger mostly, which is rather strange, because some times it does trigger (2-3 times out of 10), so the label sticks with the pointer until I press the button again.
Is this some bug or I simply does not understand something about the CreateJS and its event handlers. I tried different combinations of this. Used click instead of pressup, placing this.image.bg.gotoAndStop(2); inside the pressmove handler. Replacing pressmove handler with the stage.on('stagepressmove', handler). None did not work. this.image.bg.gotoAndStop(2); - this thing simply updates the timeframe (change the background image of the label). I do can change this image programatically (without playing timeframes) and I'm almost sure that the issue will be fixes, though I'd like to understand for myself what is wrong here or what I'm doing wrong with the event handlers.
Another, less important thing, but would be useful to know is why when pressmove event is running, the CreateJS objects stop receiving event triggers about rollover or mouseover? In DOM, by default event bubbling is working until you stop it with stopPropagation. How does it work here with CreateJS? Seems that bubbling is simply turned off here by default. How can I turn it on?
I thought I might shed some light on what I think is going on.
The normal mouse events "click", "mouseup", "rollover", "rollout", etc all function by the stage determine what the "target" of the mouse event was by default the target is the lowest-level thing that is interacted with. If you contents change while the mouse is down, it will not count as the same target when the mouseup occurs. Since positions are not re-checked without moving the mouse, the mouseover, mouseout, rollover, and rollout events may function oddly as well.
Conversely, the "pressmove" and "pressup" events do not care what is under the mouse once something is pressed. The target will always be what was pressed, which allows you to move the mouse out of the object (or even remove it), and still receive events from it. This also ensures that you receive a pressup event even if you release outside the object.
As #RandyPrad mentioned, the hitArea may solve your issue. By specifying a hit area, you are overriding the contents of your clip, so your target should always be the container (MovieClip) instead of its contents. That way no matter what is pressed inside the movieclip, it is the same target when you release. You can also get the same effect using the mouseChildren property.
movieClip.mouseChildren = false;
Hope that helps!
Please check your hit area of the button.
i think that your are playing image inside the btn is animating
please use this link http://www.createjs.com/tutorials/Mouse%20Interaction/hitArea.html

How do I change windows skin in api

I really wonder how winamp did it. I tried to change a drawing code to draw on title bar at ncpaint. it was run well but it was complex and it didn't draw,choosing another window.
I searched some source code or article but they used other ways... how do I do it?...
Well, Winamp just creates a borderless, decorationless window, and draws everything itself. Important is, that you still can attach a sysmenu to the window, so that a right click on the taskbar button gives the usual options.
If you want to get fancy you can process the WM_NCPAINT message to perform frame and title drawing yourself on a decorated window: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145212(v=vs.85).aspx
But the easier solution actually is to just emulate the standard Windows decorations and synthesize the events the standard buttons do.

Showing the keyboard in a Microsoft Surface application

I am creating an application that has multipile browsers open.
Each browser has its own keyboard to type with but I don't know how to show the keyboard in this application. When the user wants to type any URL, I have to show keyword for each user.
The normal keyboard should - at least in the surface mode - appear as soon as a textbox gets a focus. The drawback: there is only on open at a time.
If you really need to have multiple touch-keyboards, you would need to implement a custom control displaying and emulating a keyboard (you would need to handle different layouts on your own!). Basically it could be implemented as a bunch of buttons, each one adding a letter to a label. A delete button would delete the last letter. Marking, copying, deleting and so one would be interesting parts to be implementing.
We have done something similar (although only one keyboard) to emulate a handy keyboard for a promotion. To be honest: it wasn't the best experience in terms of usability (a bit worse than the included keyboard). It has fit it's need, and on screen keyboards aren't best in class experience at all (you could argue, but I like my mechanical keyboard a lot more than any virtual keyboard, so this might be a matter of taste)

Applescript and Cocoa window positions

I know that using Applescript I can change the size and position of any application's window, but is it possible to get a notification whenever a window has changed it size or position?
If thats not possible, then what I was thinking was making a thread in the background, and constantly check the positions of windows and see if they have changed, if they did then they moved.
But that would take a lot of cpu resources to constantly compare the positions/sizes of window. So is it possible? If not , is there a better way? Thanks!
I'm not sure but i think there isn't a notification for that.
I would listen for mouse events. When the mouse was dragged you can check the windoews for changes. Hope that helpa.