Make a stack close (or hide) after a click in a datagrid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Rob van der Sloot
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Sat Apr 17, 2010 9:21 am

Make a stack close (or hide) after a click in a datagrid

Post by Rob van der Sloot » Tue May 12, 2015 1:53 pm

I have a question regarding closing or hiding a stack

When clicking in a field, a stack (called ClickLists) is openend.
On every card of that stack is a datagrid with items the user can click on.
Clicking on a line of the list puts that choice into the field, from where the stack was openend.
After that I want the stack "ClickList" to dissappear without having to click a second time, hide or close, both are ok.

When I put
"Hide this stack" at the end of the script, the stack only closes when I click for a second time.

When I put
"Close this stack", the whole application starts to close, which I don't want, but also after the second click.

When I put
"break" or "pass" or "exit to top" after the line, it does not close after the first click.

When I do
send HideStack to the stack "ClickList" from the original field, it also does not work

Does someone have the answer?

Please find below the 2 scripts who are involved

1. This is the script from the field. (fld "TherapyName" of card "People" of stack "Screens")

on OpenField
open stack "ClickList"
go to card "TherapyList"
set the label of stack "ClickList" to "Therapy list"
set the loc of stack "ClickList" to 796,543
show stack "ClickList"
send "SelectTherapyList" of card "TherapyList" of stack "ClickList"
end OpenField


2. This is the script from the datagrid (of card "TherapyList" of stack "ClickList")

on mouseUp pBtnNum
if pBtnNum is 1 then
put the dgHilitedLines of group "TherapyList" into theLine
put the dgDataOfLine[theLine] of group "TherapyList" into theDataA
put theDataA["ProductName"] into fld "TherapyName" of card "People" of stack "Screens"
end if
hide stack "ClickList"
end mouseUp


thanks
Rob van der Sloot

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Make a stack close (or hide) after a click in a datagrid

Post by sritcp » Wed May 13, 2015 2:10 am

The first time you click on the datagrid, it merely focuses on the datagrid object.
*The second click opens the table field for editing (if it is a table with text field cells).* see edit
If you need your code to run on a single click (including the closing of the stack), you need to:
1. Populate the datagrid cells with buttons.
2. Modify the code that opens the stack to go ahead and focus on the datagrid already (see "focus" command in the dictionary).

Now you can code the button(s) to
1. put the chosen word into the original field, and
2. close the stack (using "send .... in 0 sec" command which executes after the handler is finished).

On an aside, you probably don't need a datagrid to achieve your objectives. A group of buttons (or a list) should do.
Datagrids are powerful but complicated. Sometimes, it is like using a hammer to swat a fly.

Regards,
Sri.


EDIT:
*The second click is registered by the cell; a double-click opens it for editing.*

Post Reply