如何在Javascript事件上从JSNI设置GWTClass字段

How to set GWT Class field from JSNI on Javascript event

本文关键字:JSNI 设置 GWTClass 字段 Javascript 事件      更新时间:2023-09-26

我有一个GWT类,它封装了Shephered Tour Javascript库:

public class SheperedTour {
    private static boolean started = false;
    private static boolean finished = false;
    private static JavaScriptObject tour;
    public static void startTour(){
        if(!started){
            _startTour();
            started = true;
        }
    }       
    public static native void cancelTour()/*-{
        @com.mycomp.app.client.local.utils.SheperedTour::tour.cancel();
    }-*/;
    public static native void _startTour()/*-{
        tour = new $wnd.Shepherd.Tour({
            defaults: {
                classes: 'shepherd-theme-arrows'
            }
        });
        @com.mycomp.app.client.local.utils.SheperedTour::tour = tour;
        tour.addStep('tour-6', {
            text: 'When done, click this to submit',
            attachTo: '#submit left',
            buttons: [
                {
                    text: 'Finish',
                    action: tour.next
                }
            ]
        });
        tour.start();
    }-*/;
}

我需要完成的是在单击"完成"按钮时设置finished静态字段。我怎样才能做到这一点?

点击"完成"按钮,从JavaScript(JSNI)调用一个Java方法,该方法设置完成的静态字段

[instance-expr.]@class-name::field-name//Syntax