Consultor Eletrônico



Kbase 15623: How to make RIGHT MOUSE button select a row in a browse ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to make RIGHT MOUSE button select a row in a browse ?

INTRODUCTION:
=============
This Technical Support library entry describes how to make RIGHT MOUSE
button select a row in a browse. It can be used in V7 and V8.

WHY YOU NEED TO KNOW THIS:
===========================
Some customers might ask how to do it. They usualy want to use right
mouse button to view some additional information and the problem is
that applying user events (such as MOUSE-SELECT-CLICK) fires
user-defined triggers, but not the built-in behavior of the object
itself.

PROCEDURAL APPROACH:
====================
Put the following piece of code either as a MOUSE-MENU-CLICK or
as a LEFT-MOUSE-CLICK trigger:

DEFINE VARIABLE h-cell AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE i-cellHeight AS INTEGER NO-UNDO.
DEFINE VARIABLE i-lastY AS INTEGER NO-UNDO.
DEFINE VARIABLE i-row AS INTEGER NO-UNDO.
DEFINE VARIABLE l-ok AS LOGICAL NO-UNDO.

h-cell = SELF:FIRST-COLUMN.

IF VALID-HANDLE(h-cell) THEN i-cellHeight = h-cell:HEIGHT-PIXELS.
ELSE i-cellHeight = 20.

i-lastY = LAST-EVENT:Y.

IF i-lastY >= i-cellHeight AND
i-lastY <= i-cellHeight * (SELF:NUM-ITERATIONS + 1) THEN
DO:
i-lastY = i-lastY - i-cellHeight / 2.
i-row = i-lastY / i-cellHeight.
l-ok = SELF:SELECT-ROW(i-row).
END.

Explanation of the code:
------------------------
The first IF is because not all browses are updatable so to make the
code as universal as possible this checks whether the handle of the
first enabled column is valid. If so then it takes height from it. If
not it is necessary to check whether the value 20 is OK (to see how
refer to the paragraph "PROCEDURES OR UTILITIES". This IF and the
previous line h-cell = SELF:FIRST-COLUMN can be used in V8 ONLY !!!
The second IF checks whether or not it makes sence to select the row.
If this would not be there it would give errors when either column
header or the "tail" of the browse would be clicked on.

ONLINE PROCEDURES OR UTILITIES:
===============================
How to find out a hieght of a row (this applies to V8 ONLY):
- create a browse with an enabled field
- edit a trigger ON VALUE-CHANGED OF browse:

DEFINE VARIABLE h-cell AS WIDGET-HANDLE NO-UNDO.
h-cell = SELF:FIRST-COLUMN.
MESSAGE h-cell:HEIGHT-PIXELS VIEW-AS ALERT-BOX INFORMATION.

- run the code and click on a row in the browse, the value returned by
the message is height of the row
- now you can hardcode the value for non-updatable browses

REFERENCES TO WRITTEN DOCUMENTATION:
====================================
All used attributes are described in:
- V7 "Language Reference Volume 2" - Appendix A, "Attributes"
- V8 "Language Reference: Widgets, Attributes & Methods, Events &
Indexes"

Browse widget is described in:
- V7 "Programming Handbook" - Chapter 8, "Database Access"
- V8 "Programming Handbook" - Chapter 9, "Using the Browse Widget"

Progress Software Technical Support Note # 15623