I'm creating an app with a table. I need to create an option for clicking on the table's cells. couldn't find a way to do it instead of using al lot of buttons... Any idea?
thanks

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller


Code: Select all
on mouseDown
  -- Get clicked line:
  put word 2 of the clickLine into tLine
  -- Get clicked column:
  put the clickH into tH
  put 0 into tCell
  repeat for each item tWidth in the tabstops of me
    if tH < tWidth then exit repeat
    add 1 to tCell
  end repeat
  -- Select the clicked text:
  set the itemdel to tab
  select item tCell of line tLine of me
  -- Report details if needed:
  put "Line="& tLine && "Item="& tCell && \
        "Text="& the text of item tCell of line tLine of me \
        into fld "Display"
end mouseDownCode: Select all
set the itemDel to tab
put "foo" into item 3 of line 2 of fld "yourtableField"Code: Select all
on mouseDown
   put the topLeft of me into XY
   put the clickLoc into tLoc
   ask "What?"
   put it into temp
   set the itemDel to tab
   put temp into the item that corresponds to the distance from XY to tLoc
end mouseDown
 
  
No, you helped me a lot!


Thanks, BigGameOver. I've lost count of the number of times I've posted a solution here and the conversation keeps going like no one saw it. Glad this one helped.
Is this like asking "Are you asleep?"Are my posts not visible here?
Code: Select all
on mouseDown
   put the textheight of me into tHeight
   put item 1 of the  clickLoc - item 1 of left of me into x
   put item 2 of the  clickLoc - item 1 of top of me into y
   
   put y div theight into lineNum
   if y mod tHeight <> 0 then add 1 to lineNum
   
   repeat with z = 1 to the number of items of the tabStops of me
      if item z of the tabstops of me > x then
         put z into itemNum
         exit repeat
      end if
   end repeat
   ask "What?"
   set the itemDel to tab
   put it into item itemNum of line lineNum of me
end mouseDown
Not quite. Subsequent posts seem unlikely to have been written while asleep.

