Hello,

I would like to make a minor adjustment to the way tables work in an 
NSTextView, but as the tables panel is a bit of a black box and as the table 
classes - NSTextTable and NSTextTableBlock - aren't the easiest thing to use 
(they are straightforward if you just want to create a table programmatically, 
but messing around with them live gets tricky), I am having difficulties 
finding a way of doing what I want.

What I would like to do is this: if the user is in the last column in the last 
row of a table and hits the tab key, another row should be created below and 
the cursor placed in the first cell. This would be the equivalent of the user 
clicking in the table panel to create an extra row and then hitting tab, so in 
theory, this is what I would like to achieve programmatically to override the 
current behaviour:

1) Override NSTextView's -insertTab: to containing the following.
2) Inside -insertTab:, detect if the typing attributes' paragraph style has a 
text table block associated with it.
3) If so, detect if it is the last cell in the last row (I'd probably have to 
account for R-to-L text here).
4) If so, somehow simulate the user clicking on the "add new row" button in the 
tables panel.
5) Continue with super's -insertTab: so that the cursor moves to the first cell 
in the new row.

Needless to say, steps 3 and 4 are the difficult parts here, as all the actions 
for things such as "add extra table row" seem to be private, and there doesn't 
seem to be an obvious way of detecting whether a given cell is in the last 
column or row.

Has anyone had any experience with overriding NSTextView's standard 
table-creation behaviour, or has anyone got any ideas about how I might achieve 
the above?

Many thanks and all the best,
Keith


      
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to