GtkD: How to respond to cell edit's?

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 18 10:06:42 PDT 2017


On 18-08-17 02:30, Johnson Jones wrote:
> On Friday, 18 August 2017 at 00:27:05 UTC, Johnson Jones wrote:
>> I should also mention that when I use an ID to do what I want(again, 
>> something I don't want to do), I also need to get the column that was 
>> edited. This is because I'm using one delegate for all the edits.
>>
>>
>> auto cb = delegate(string index, string text, CellRendererText r)
>> {
>>     // How to get the column of that we are editing? An index would be 
>> fine.
>>     writeln(index, " - ", text);
>> };
>>
>> RT1.addOnEdited(cb);
>> RT2.addOnEdited(cb);
>> RT2.addOnEdited(cb);
>>
>> Looks like I might have to use separate edit handlers ;/
>>
>> I wonder if I can somehow template it so I can do something like
>>
>>
>> RT1.addOnEdited(cb!1);
>> RT2.addOnEdited(cb!2);
>> RT2.addOnEdited(cb!3);
>>
>> without having to write a bunch of code to make it happen. Maybe there 
>> is a library function that can help?
> 
> Obvious it is easy when you have ID's, but this is meant for the 
> original case where I'm not using ID's.

A far as i can tell using id's is the only option.

You can use a templated function as a delegate:

```
void cb(int column)(string index, string text, CellRendererText r)
{
	writeln(column, " - ", index, " - ", text);
}

RT1.addOnEdited(&cb!1);
RT2.addOnEdited(&cb!2);
RT2.addOnEdited(&cb!3);
```

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list