[Gambas-user] Re; Grid / Double Click
ron
ronstk at ...239...
Fri May 4 11:03:18 CEST 2007
On Friday 04 May 2007 10:11, Gareth Bult wrote:
> Yup, this is the issue I have .. it can be made to work "mostly" ..
>
> However, writing applications that work "mostly" doesn't really do it
> for me ... :(
>
> My solution for now is to use a keyboard event rather than a double
> click ...
> If anyone has a working calculation I'm all ears ... :)
>
> Gareth.
>
This routine checks if the mouse x/y is above a cell and not in the space below/right of it
' waiting for updated gambas, function is add on my request
PUBLIC FUNCTION hGrid at ...1692...(x AS Integer, Y AS Integer) AS Boolean
' returns true if out range
DIM gx, gy AS Integer
DIM gc, gr AS Integer
gx = 0
gy = 0
gc = 0
gr = 0
WITH hGrid
gx = .Columns[0].Width
WHILE x > gx
INC gc
IF gc > (.Columns.Count - 1) THEN RETURN TRUE
gx += .Columns[gc].Width
WEND
gy = .rows[0].Height
WHILE y > gy
INC gr
IF gr > (.rows.Count - 1) THEN RETURN TRUE
gy += .rows[gr].Height
WEND
.Column = gc
.Row = gr
END WITH
END
As mentioned the GridVie.Find is implement and here as private subroutine 'hGrid at ...1692...'
hFrid is the handle for the GridView control.
The calculation is here done.
In fact I set the .Row and .Column properties so after a call the return boolean
tells you if it is a valid hit or not.
When valid the GridView.Row and GridView.Column are set correct.
-----------------
Here I did use the service
grdFields is the name of the GridView and the hGrid handle of it
GridCtrlHide routine did hide the overlay controls for editing.
GridCtrlShow routine shows the appropriate control for the .Row
The Gridview is used with on the row the value/properties of a field in database table.
Every row has his own control as textbox/listbox/combobox/checkbox
Every column is the representation of a field.
The result is transformed to a MySQL query
Code is never been clean up of remarks etc.(shame to me)
PUBLIC SUB grdFields_MouseDown()
'PRINT "grdFields_MouseDown:"; grdFields.Row; "/"; grdFields.Column
'PRINT mouse.X
'if ctrl then save value if editing
IF ctrTBX.Visible THEN ctrTBXSave
GridCtrlHide
'and go to new position
' IF grdFields at ...1692...(mouse.x, mouse.y) THEN RETURN
' GridCtrlShow(grdFields.Row, grdFields.Column)
END
PUBLIC SUB grdFields_MouseMove()
IF mouse.Left THEN
'PRINT "grdFields_MouseMove"
'check in gridcell
IF ME.grdFields at ...1692...(mouse.X, mouse.Y) THEN RETURN
' IF ME.grdFields.Find(mouse.X, mouse.Y) THEN RETURN
grd.CtrlHide
Drag.Icon = picture["img/16/gambas.png"]
drag(grdFields, MIME_TYPE_GRID)
END IF
END
PUBLIC SUB grdFields_MouseUp()
DIM vVal AS Variant
'PRINT "grdFields_MouseUp"; grdFields.Row; "/"; grdFields.Column
GridCtrlHide
IF grdFields at ...1692...(mouse.x, mouse.y) THEN RETURN
IF grdFields.row = grd.GRDVIS THEN
' row/column for write data in grid
grdFields.Tag = [grdFields.Row, grdFields.Column]
vVal = IIf(UCase(grdFields[grdFields.Row, grdFields.Column].Text) = "YES", "No", "Yes")
GridWrite(vVal)
ELSE
GridCtrlShow(grdFields.Row, grdFields.Column)
ENDIF
END
-----
Ron
More information about the User
mailing list