ELM : Manage side effect - elm

isn't onClick (button click) a side side effect.
in ELM language we can listen for a click event without getting hand dirty with Task and command.
isn't a click event a side effect or has side effect, if so why we can listen to button click event without using Task

In Elm you don't need Tasks to handle DOM events.
You are absolutely right, user input is a side-effect.
As of 0.17.0, user input from Html elements is handled behind the scenes in Html.App and most of DOM events are triggered as messages to your update function.
Any HTML element has a type signature of Html msg, which hints you towards the idea described above.

Related

How do I create a click event in Verold?

I am experimenting with Verold (http://verold.com), a web based tool that allows you to create webgl 3d experiences. I have made this simple prototype:
http://www.verold.com/projects/54270b01497675020000007d
Right now my animation occurs on load. I'd like to "replay" the animation on click of the background (or on another object).
I could not find the appropriate event to make a "button" or click event.
You have a couple of options.
You can use an Event Handler component in Verold, and listen to the Pick event on any object in your scene.
Alternatively, if you're building an API project in Verold, you can create a button in your HTML page and trigger an event from there:
VAPI.globalEvents.trigger('myEvent');
Then in Verold, add an EventHandler that listens to the myEvent Custom event.
Ross

How can I give focus to WinJS.UI.settingsFlyout after animation?

I'm invoking a WinJS.UI.settingsFlyout element via Javascript using WinJS. Inside the HTML element of the settingsFlyout, I have a text input field that I would like to receive focus after the animation of the flyout occurs. I've tried to use jQuery's .focus() method, but it does not work because I do not think the flyout is focused after it completes its animation. I have to click twice on the input field to begin typing. I click once to get the flyout in focus, and then click another time to get the field in focus. Quite annoying. Is there a way to implement auto focusing of input fields within a WinJS.UI.settingsFlyout?
Have you tried?
settingsFlyout.addEventListener("aftershow", function(){
$('#inputId').focus();
});

How to propagate an event up to handler chain (Carbon) after it handled by my custom handler?

I need to handle a Tab key press in my application. In some conditions I want to do some stuff in my handler and suppress further event handling and in other cases I just skip and let other standard handlers to handle this event.
Here is my very simple app where I'm trying to do it.
https://github.com/prudnikov/TestGlobalShortcut/blob/master/TestGlobalShortcut/AppDelegate.m
It catches tab press but it always suppresses further event handling. I mean when I press Tab in the text editor the tab key is not inserted.
Can you advise what should I do to propagate standard event handlers?
I don't think you can do that using RegisterEventHotKey. But unless you need to receive the tab key when your app is not frontmost, you should not be using RegisterEventHotKey. Use a regular Carbon Event handler, or use Cocoa event handling techniques.

Detecting Mouse Wheel Events When Form Does Not Have Focus In Visual Basic 2010

I want to make an auto log off feature, I want to detect if there is any user input, and if there isn't the user will be automatically logged off. So I want to know how to detect mouse wheel events when the form doesn't have focus. Any help would be much appreciated.
Is it possible, because I have searched everywhere and can't seem to find it.
Thanks.
According to the WM_MOUSEWHEEL Message definition:
"Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it."
The only way you could possibly do this is with a global hook but I very much doubt you can do this using managed code.

Capturing Keyboard Events in Dojox GFX

Is it possible to capture keyboard events within a diagram produced using Dojox.GFX?
We have a simple graphical application which involves some shapes drawn on a surface. We would like to add some simple keyboard interaction, e.g. using the Delete key to delete a shape, and using "Ctrl+A" to select all shapes.
I have tried adding dojo.connect and shape.connect statements for "onkeypress" and "onkeyup", but they never seem to get triggered. We are already capturing mouse events and these are working fine.
Thanks
David
Keyboard events are not pointed, they are essentially global. You should catch them globally attaching a handler to document or body.
Thanks, now working!
In my case this was a portlet so the <body> tag was not available, but I used a <div> tag instead:
<div id="queryPortlet" onkeydown="handleKeydown(event.keyCode);" onkeyup="handleKeyup(event.keyCode);">
The other thing I had to watch for was not intercepting keystrokes if the focus was in a text input field. I had to write some code to keep track of when the focus was in a text field, by adding onfocus() and onblur() handlers to all such fields. This was a slight pain but was the only way I could find to do that.