Datagrid lost focus to next cell

zryip theSlug zryip.theslug at gmail.com
Sat Jun 19 09:03:34 EDT 2010


Hi Josep,

When a DataGrid is in a group and you want to navigate inside it, it
seems that it lost the focus, resulting to this odd behavior.

It's probably a bug.

I will propose you a possible solution to help. It consists to change
the default column behavior of your Data Grid.
In this custom behavior you can fix the bug to let your Data Grid in a
group, performs as you expect.

1) Create a button, name it "Custom Behavior" and set its content script to:


-- This script defines the behavior of a table column's custom template.

on FillInData pData
    -- This message is sent when the Data Grid needs to populate
    -- this template with the column data. pData is the value to be displayed.

    -- Example:
    set the text of field 1 of me to pData
end FillInData


on LayoutControl pControlRect
    -- This message is sent when you should layout your template's
controls if your template is a group.
    -- If your template is not a group then there is no work to do here.
    -- You can use items 1 through 4 of pControlRect as boundaries for
laying out your controls.

    -- Example:
    set the rect of field 1 of me to pControlRect
end LayoutControl


setprop dgHilite pBoolean
    -- This custom property is set when the highlight of your column
template has
    -- changed. You only add script here if you want to customize the highlight.

    if pBoolean then
        set the foregroundcolor of me to the dgProp["hilited text
color"] of the dgControl of me
    else
        set the foregroundcolor of me to empty
    end if
end dgHilite


getprop dgDataControl
    -- Required by library so that it can locate your control.
    return the long id of me
end dgDataControl


-- Data grid will call EditValue if a user action asks to edit cell content.
command EditValue
    if there is a field 1 of me then
        EditFieldText the long id of field 1 of me, the dgIndex of me,
the dgColumn of me
        EditFieldText the long id of field 1 of me, the dgIndex of me,
the dgColumn of me
    end if
end EditValue


on mouseDoubleUp pMouseBtnNum
    -- Example of how to edit the contents of a field (assuming the
column template this is
    -- associated with is a field).
    -- By passing the index of the record linked to the copy of this
template and the name of the
    -- column being edited the data grid will automatically save the
changes the user
    -- makes and refresh the UI by calling FillInData and resizeControl.
    if pMouseBtnNum is 1 then
        if word 1 of the target is "field" then
            ## word 1 to -2 because of unique numbers (i.e. 0001,
0002) that the data grid adds to each
            ## copy of this template that is made.
            if the dgProps["allow editing"] of the dgControl of me \
                    and the dgColumnIsEditable[the dgColumn of me] of
the dgControl of me then
                EditCellOfIndex the dgColumn of me, the dgIndex of me
                exit mouseDoubleUp
            end if
        end if
    end if

    pass mouseDoubleUp
end mouseDoubleUp


--> The trick here is to double the line:
EditFieldText the long id of field 1 of me, the dgIndex of me, the
dgColumn of me

It force the focus to stay inside the field.

2) Assign this new column behavior with this code:

set the dgProp["default column behavior"] of grp "MyDataGrid" to the
long id of button "Custom Behavior"

3) At last, remove the dim focus behavior by executing this script:

set the dgProp["dim on focusOut"] of grp "MyDataGrid" to true

You can expect a better solution than mine, but for now it fix the problem 8-)

Regards,

2010/6/19, JosepM <jmyepes at mac.com>:
>
> Hi,
>
> I have a datagrid inside a group. I add a row and doubleclick to edit the
> cell value, and pressing tab key jump to the next cell. But If I fill some
> value and press tab, the next cell is edit but lost the focus and the
> datagrid still in edit mode but without the focus.
>
> Why? The same datagrid with the group run fine.
>
>
> Salut,
> Josep
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Datagrid-lost-focus-to-next-cell-tp2260851p2260851.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>


-- 
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc



More information about the use-livecode mailing list