【问题标题】:Prolog mouse hover recognizerProlog 鼠标悬停识别器
【发布时间】:2016-04-13 11:19:52
【问题描述】:

如何在 prolog 中向对象添加悬停识别器? 我希望在用户用鼠标悬停对象时调用规则。

类似的东西:

send(S,recogniser,click_gesture(left,'',single,and(message(@prolog, add ,X, Y)))).

但对于鼠标悬停手势。

【问题讨论】:

  • 您使用的是什么 Prolog 实现?任何面向 GUI 的东西都是非常具体的实现。 Prolog 没有内置的 GUI 支持。
  • 我正在使用 SWI-prolog。

标签: hover prolog mouseover gesture


【解决方案1】:

您必须使用鼠标的事件。 这是一个例子:我有一个按钮,当鼠标悬停在按钮上时,形状被修改。 您可以知道鼠标何时进入对象区域以及何时离开。

:- pce_begin_class(my_button, button).

variable(enter, any, both, "flag pour le dessin lorsque la souris survole le bouton").

event(G, Ev:event) :->
    ( send(Ev, is_a, area_enter) ->
      send(G, slot, enter, in),
      send(G, redraw)

    ;   send(Ev, is_a, area_exit) ->
        send(G, slot, enter, out),
        send(G, redraw)
    ;  send_super(G, event, Ev)
    ).

initialise(P, Lbl):->
    send(P, send_super, initialise,Lbl),
    send(P, font, font(times, normal, 15)),
    send(P, compute),
    send(P, slot, enter, out).

% méthode d'affichage redéfinissable
'_redraw_area'(P, _A:area):->
        "Draw a "::
    % on affiche le texte
    get(P, label, Lbl),
    new(Str1, string(Lbl)),
    get_object(P, area, area(X0,Y0,W,H)),
    (      get(P, status, preview) -> X is X0 + 2, Y is Y0 + 2, Up = @off
    ;      X = X0, Y = Y0, Up = @on),

    (   get(P, slot, enter, out) ->  new(E, elevation(1)); new(E, elevation(3))),
    send(P, draw_box, X, Y, W, H, 5, E, Up),
    send(P, draw_text, Str1, font(times, normal, 15), X, Y, W, H, center, center),

    get(P, default_button, @on),
    X1 is X+3, Y1 is Y+3, W1 is W - 6, H1 is H- 6,
    send(P, save_graphics_state),
    send(P, graphics_state,texture := dotted),
    send(P, draw_box, X1, Y1, W1, H1, 5),
    send(P, restore_graphics_state).
:- pce_end_class.

【讨论】:

    猜你喜欢
    • 2011-08-04
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2011-05-26
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多