Package js.dom

Source Code of js.dom.User

/*
* Copyright (C) 2013 Nameless Production Committee
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*          http://opensource.org/licenses/mit-license.php
*/
package js.dom;

import static js.lang.Global.*;
import js.dom.Element;
import js.dom.UIEvent;

/**
* @version 2013/10/20 10:02:05
*/
public class User {

    /**
     * <p>
     * Emulate user click action.
     * </p>
     *
     * @param element
     */
    public static void click(Element element) {
        if (element != null) {
            UIEvent event = document.createEvent("UIEvent");
            event.initEvent("click", true, true);

            element.dispatchEvent(event);
        }
    }

    /**
     * <p>
     * Emulate user mouse down action.
     * </p>
     *
     * @param element
     */
    public static void mouseDown(Element element) {
        if (element != null) {
            UIEvent event = document.createEvent("UIEvent");
            event.initEvent("mousedown", true, true);

            element.dispatchEvent(event);
        }
    }
}
TOP

Related Classes of js.dom.User

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.