Page 2 of 2


Posted: 22 May 2014 22:13
by Elena Efimova

This code does not work in Visual Prolog 7.4:

Code: Select all

predicates     onButtonMouseDown : window::mouseDownListener. clauses     onButtonMouseDown(_Source, Point, ShiftControlAlt, Button) :-         stdio::writef("Point = %, ShiftControlAlt = %, Button = %\n", Point, ShiftControlAlt, Button).
But getFocusListener works well for right-mouse clicks:

Code: Select all


Code: Select all

predicates     onButtonGetFocus : window::getFocusListener. clauses     onButtonGetFocus(Button):-         Button:setText("!").

Posted: 23 May 2014 20:11
by Thomas Linder Puls
Sorry, I forgot to "backwards-check" my code, my suggestion will not work until the next release.

The mouse down event does reach the button, but in Vip7.4 (and earlier) you will have to attach a native event handler to get it.

Normally, I would not recommend extending standard controls with unusual features (because people should get the behavior they expect), but here we are not using the button as a button: we are using a button to "fake" something completely different.

The focus listener will be invoked whenever the button gets focus (obviously).

I guess that this can only happen if we right click the button. Other potential ways would be if we TAB to the button, but I don't think these buttons should have tab-stop. Left-clicking also brings focus to the button, but since we destroy the button on a left click I guess the focus event will never arrive.