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
-
Gage
- Livecode Opensource Backer

- Posts: 224
- Joined: Tue Mar 26, 2013 8:59 pm
Post
by Gage » Sat Aug 16, 2014 12:43 am
Hi all!
Hopefully my creative title hasn't thrown many of you off

My mission right now is simple. I want to find the rect of a cell in a DG Table I have. In my dreams, the script would look something like this:
put the rect of the dgIndex of me into theRect
...and yes, this dream script assumes I am in the Behavior Script of the index whose rect I am hunting for, which IS the case. Hopefully this can be done! Let me know if you have any pointers.
Thanks in advance!
Phil E.
-
sritcp
- Posts: 431
- Joined: Tue Jun 05, 2012 5:38 pm
Post
by sritcp » Sat Aug 16, 2014 1:38 am
Hi Gage:
Look for a handler named
command EditValue
in the default column behavior script of the DataGrid.
Edit it to add a line as shown:
Code: Select all
command EditValue
EditFieldText the long ID of me, the dgIndex of me, the dgColumn of me
put the rect of the long ID of me into gRect -- THIS IS THE LINE TO ADD
end EditValue
I have used a global gRect to hold the value just for demonstration; you should put it in a custom property of your DataGrid.
When the user double-clicks a field, this will put the rect into the variable. If you need it in other situations, you can modify it suitably.
Regards,
Sri.
-
Gage
- Livecode Opensource Backer

- Posts: 224
- Joined: Tue Mar 26, 2013 8:59 pm
Post
by Gage » Sat Aug 16, 2014 2:36 am
Hi Sri,
Thanks for your response!
I implemented your suggestion, but my code breaks in the EditValue handler when it gets to the line with the EditFieldText call.
I am suspicious that this is because I removed the default code that referred to 'field 1 of me' since I have no fields in this particular cell at all. However, my code does look exactly the same as your code (I copy/pasted the handler over the old one).
Best,
Phil E.
-
sritcp
- Posts: 431
- Joined: Tue Jun 05, 2012 5:38 pm
Post
by sritcp » Sat Aug 16, 2014 3:55 am
Hi Phil:
If it crashes at the first line (EditFieldText ....) then it has nothing to do with the fact that you added a second line to this handler. It should crash without the added line, too. Does that happen (when you double click)?
When you double click, the EditValue is triggered. This is when "me" refers to the cell (field) that was clicked on.
I don't understand what you mean by "I have no fields in this particular cell at all". If it is a table, it is going to contain a value in a cell. The container is "field 1" of the cell. May be you shouldn't cut it out.
The code I posted works with the default column template code. I checked.
Regards,
Sri.
Edit: You can put the added line BEFORE the EditFieldText..... line. This way, it would have saved the rect in the global variable before it crashes. Thus, it should show up in the variable watcher.
Also, you need to define the global up top (if you are cutting and pasting my code).
Lastly, what was the error description?
-
Gage
- Livecode Opensource Backer

- Posts: 224
- Joined: Tue Mar 26, 2013 8:59 pm
Post
by Gage » Sat Aug 16, 2014 4:13 am
Sri,
I actually need to call this handler via script from another handler I wrote. So, no, I am not double-clicking to enter the handler.
And this may be a reiteration of something you already know, but I do not have a "field" object per se to double-click, anyway. So, if the cell itself counts as a field, that makes sense. I was just saying my row template for that column has no fields placed in it (aside from the title field, I guess...)
Yes, I handled the global as necessary, thank you for being extra clear about that, too.
I didn't receive a LiveCode-generated error message at all. My script just stopped giving any indication that it was executing (for at least 25 seconds).
As a note...
I did find a sort of workaround. I just added a Background graphic into the Row Template and sized it to pControlRect then I refer to its rect later on.
The funky part about what I'm doing (I suppose) is that I have a very versatile LayoutControl handler written, and I am using it to position newly added objects that may not have been there the first time the DG was populated, since the rules to do so are all in place within my handler. Only thing is that when I call LayoutControl again from my custom handler in the Behavior Script to do this, I don't have an easy way of synthesizing the pControlRect paramater that was originally generated automatically while the whole DG rendered.
Hopefully that wasn't too long-winded to be clear.
Thanks for your continued attention!
All the best,
Phil E.
-
sritcp
- Posts: 431
- Joined: Tue Jun 05, 2012 5:38 pm
Post
by sritcp » Sat Aug 16, 2014 2:00 pm
Phil,
Sorry, it wasn't clear from your original post what you were really trying to do. EditField won't work (when there is no field, obviously).
I just added a Background graphic into the Row Template and sized it to pControlRect then I refer to its rect later on.
A clever workaround!
Only thing is that when I call LayoutControl again from my custom handler in the Behavior Script to do this, I don't have an easy way of synthesizing the pControlRect paramater that was originally generated automatically while the whole DG rendered.
I am not entirely sure I understand. Why couldn't you capture the rect (e.g., into a global) at the end of the previous rendering? (Likely I haven't understood the issue very well)
Regards,
Sri
-
Gage
- Livecode Opensource Backer

- Posts: 224
- Joined: Tue Mar 26, 2013 8:59 pm
Post
by Gage » Sat Aug 16, 2014 10:14 pm
Hi Sri,
In writing that, I was kind of summarizing my original problem, which only existed in absence of the workaround. The workaround does solve this, you're totally right. Sorry for being confusing!
The last little bit I am scratching my head about is that I thought DGs would resize their row height automatically to the largest object in them. Is that not the case? If not, how can I make the row accommodate a dynamically growing height? (*the fixed control height checkbox is disabled in the Property Inspector*).
Thanks!
Regards,
Phil E.
-
sritcp
- Posts: 431
- Joined: Tue Jun 05, 2012 5:38 pm
Post
by sritcp » Sun Aug 17, 2014 6:43 pm
Hi Phil:
Setting the "fixed row height" to false has never worked for me with a table. The row height defaults to the number stated in the row height field given in the inspector just below it (or you can set it by script)
Either it is a bug or the automatic row height adjustment applies to forms, not tables.
May be someone more familiar with DataGrids can answer.
Regards,
Sri.
-
Gage
- Livecode Opensource Backer

- Posts: 224
- Joined: Tue Mar 26, 2013 8:59 pm
Post
by Gage » Sun Aug 17, 2014 11:00 pm
Hello Sri
I think you're totally right. I have been sifting through the available resources, and have been getting a similar impression. It doesn't seem like I can have rows in the same column that have different heights than one another.
Occasionally, I even set the row height to, say, 40, and have most of my controls being 20 pixels in height, and the next row of the DG Table will render WITHIN the open space on the previous line!! Talk about mind boggling
Anyway, I will work within this limitation for now and consider porting everything to either a DG Form or a custom designed scrolling group at a later time.
As always, thanks so much for your input!
Best,
Phil E.