Create User Control

Discussions related to Visual Prolog
Elena Efimova
Posts: 7
Joined: 1 Sep 2006 13:02

Re:

Unread post by Elena Efimova » 22 May 2014 22:13

Hello!

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

Button:addGetFocusListener(onButtonGetFocus),

Code: Select all

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

User avatar
Thomas Linder Puls
VIP Member
Posts: 1622
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 23 May 2014 20:11

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.
Regards Thomas Linder Puls
PDC

Post Reply