Is this the right list?
Excuse me, but is this the correct list to ask questions about MacRuby programming? -- --Zonbi.
I believe it is. How can we help you? - Matt On Mon, Jan 12, 2009 at 1:44 PM, Timothy McDowell <tmcdowell@gmail.com>wrote:
Excuse me, but is this the correct list to ask questions about MacRuby programming?
-- --Zonbi.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On Mon, Jan 12, 2009 at 3:15 PM, Matt Aimonetti <mattaimonetti@gmail.com>wrote:
I believe it is. How can we help you?
Thanks, and here is my dillema: I have a bit of code that is something like this class MyController attr_writer(:button, :textview) def clicked(sender) @textview.insertText("Button clicked!\n") end end :textview is linked to an NSTextView object via InterfaceBuilder. Now the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it? -- Thanks, --Zonbi.
:textview is linked to an NSTextView object via InterfaceBuilder. Now the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work. You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^ On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart < vincent.isambart@gmail.com> wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now the
purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
Y'know what, that doesn't seem to work actually. No '<<' method, and setCharacters/setWords works, but nothing shows up. On Mon, Jan 12, 2009 at 4:34 PM, Timothy McDowell <tmcdowell@gmail.com>wrote:
Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^
On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart < vincent.isambart@gmail.com> wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now the
purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
-- --Brains.
How about @text_view.setString("foo") or as @text_view.string = "foo" ? http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas... /apple_ref/doc/uid/20000367-setString_ - Eloy On 13 jan 2009, at 00:46, Timothy McDowell wrote:
Y'know what, that doesn't seem to work actually. No '<<' method, and setCharacters/setWords works, but nothing shows up.
On Mon, Jan 12, 2009 at 4:34 PM, Timothy McDowell <tmcdowell@gmail.com> wrote: Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^
On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart <vincent.isambart@gmail.com
wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
-- --Brains. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
textView seems rather tedious compared to textField to me. Here is what I do (which does work when the view is made not editable): class Controller attr_writer :text_view #linked to the IB textView on your window def awakeFromNib replace_all_range = NSRange.new(0, @text_view.textStorage.length) @text_view.replaceCharactersInRange(replace_all_range, withString:"a new string") end end I saw this originally when learning Ruby / Cocoa in Brian Marick's RubyCocoa book - which is available at the moment as a PDF (it has not been released yet to paper I believe) from the Pragmatic Programmers. Both Marick's and Hillegas's books are important reads for the beginning (eg me) macruby programmer. Cheers, J On Jan 13, 2009, at 1:22 AM, Eloy Duran wrote:
How about @text_view.setString("foo") or as @text_view.string = "foo" ?
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas... /apple_ref/doc/uid/20000367-setString_
- Eloy
On 13 jan 2009, at 00:46, Timothy McDowell wrote:
Y'know what, that doesn't seem to work actually. No '<<' method, and setCharacters/setWords works, but nothing shows up.
On Mon, Jan 12, 2009 at 4:34 PM, Timothy McDowell <tmcdowell@gmail.com
wrote: Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^
On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart <vincent.isambart@gmail.com
wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
-- --Brains. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks a bunch, but I believe I'm going to have to switch frameworks/libraries. I believe I just read that opening TCPSockets causes errors in MacRuby.. On Mon, Jan 12, 2009 at 11:36 PM, John Shea <johnmacshea@gmail.com> wrote:
textView seems rather tedious compared to textField to me. Here is what I do (which does work when the view is made not editable):
class Controller attr_writer :text_view #linked to the IB textView on your window
def awakeFromNib replace_all_range = NSRange.new(0, @text_view.textStorage.length) @text_view.replaceCharactersInRange(replace_all_range, withString:"a new string") end
end
I saw this originally when learning Ruby / Cocoa in Brian Marick's RubyCocoa book - which is available at the moment as a PDF (it has not been released yet to paper I believe) from the Pragmatic Programmers. Both Marick's and Hillegas's books are important reads for the beginning (eg me) macruby programmer.
Cheers, J
On Jan 13, 2009, at 1:22 AM, Eloy Duran wrote:
How about @text_view.setString("foo") or as @text_view.string = "foo" ?
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas... /apple_ref/doc/uid/20000367-setString_
- Eloy
On 13 jan 2009, at 00:46, Timothy McDowell wrote:
Y'know what, that doesn't seem to work actually. No '<<' method, and setCharacters/setWords works, but nothing shows up.
On Mon, Jan 12, 2009 at 4:34 PM, Timothy McDowell <tmcdowell@gmail.com>wrote:
Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^
On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart < vincent.isambart@gmail.com> wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now
the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
-- --Brains. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- --Brains.
Generally when you are creating a Cocoa application with Ruby, you'll want to use frameworks that use Cocoa idioms. This holds especially true for async operations, such as working with sockets. So in this case I take would look at http://code.google.com/p/cocoaasyncsocket/ This is used by, for instance, LimeChat (A RubyCocoa & MacRuby application). But note that even with this framework, you might encounter MacRuby problems. This is the other side of using young technologies. If you can't deal with that right now, but would like to use Ruby, I would encourage you to take a look at RubyCocoa. Cheers, Eloy On 13 jan 2009, at 18:01, Timothy McDowell wrote:
Thanks a bunch, but I believe I'm going to have to switch frameworks/ libraries. I believe I just read that opening TCPSockets causes errors in MacRuby..
On Mon, Jan 12, 2009 at 11:36 PM, John Shea <johnmacshea@gmail.com> wrote: textView seems rather tedious compared to textField to me.
Here is what I do (which does work when the view is made not editable):
class Controller attr_writer :text_view #linked to the IB textView on your window
def awakeFromNib replace_all_range = NSRange.new(0, @text_view.textStorage.length) @text_view.replaceCharactersInRange(replace_all_range, withString:"a new string") end
end
I saw this originally when learning Ruby / Cocoa in Brian Marick's RubyCocoa book - which is available at the moment as a PDF (it has not been released yet to paper I believe) from the Pragmatic Programmers. Both Marick's and Hillegas's books are important reads for the beginning (eg me) macruby programmer.
Cheers, J
On Jan 13, 2009, at 1:22 AM, Eloy Duran wrote:
How about @text_view.setString("foo") or as @text_view.string = "foo" ?
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas... /apple_ref/doc/uid/20000367-setString_
- Eloy
On 13 jan 2009, at 00:46, Timothy McDowell wrote:
Y'know what, that doesn't seem to work actually. No '<<' method, and setCharacters/setWords works, but nothing shows up.
On Mon, Jan 12, 2009 at 4:34 PM, Timothy McDowell <tmcdowell@gmail.com
wrote: Haha, I scoured that documentation for an hour! Thanks a bunch. ^_^
On Mon, Jan 12, 2009 at 4:16 PM, Vincent Isambart <vincent.isambart@gmail.com
wrote:
:textview is linked to an NSTextView object via InterfaceBuilder. Now the purpose of this view is to work as the display for text coming from a MUD (Multi-user domain/dungeon). I have it set to noneditable but selectable. My above code doesn't work. I allow it to be editable, and the code does work. Is there a way to prevent user-editing but to allow my code to edit it?
Extract from Apple's Objective-C insertText: documentation: This method is the entry point for inserting text typed by the user and is generally not suitable for other purposes. Programmatic modification of the text is best done by operating on the text storage directly. Because this method pertains to the actions of the user, the text view must be editable for the insertion to work.
You can do for instance @text_view.textStorage << 'my text' But be careful, text inserted like this ignores the current font attributes of the text view. You have to add them yourself.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Thanks, --Zonbi.
-- --Brains. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- --Brains. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (5)
-
Eloy Duran
-
John Shea
-
Matt Aimonetti
-
Timothy McDowell
-
Vincent Isambart