ok I think I am done with it. Tested also on Macos and it looks that it works fine. So it works fine both on Macos and Windows. Work on the same Nautilus window but also across multiple Nautilus windows. A summary of what I have done, I have created a class variable methodsToBeCopied, storing the methods to be copied marked by the copyMethod and then pasted by the pasteMethod in NautilusUI class. I have added them in the method right click menu and also I have added paste method in the class right click menu in case you have a class that has no methods and you want to paste the copied methods. The procedure works with one method but also multiple methods can be copied and also they can be pasted multiple times. So if you want to past the same methods again and again across different classes thats possible too. I decided to abandon the Paste New idea since its trivial to just rename the pasted method and I don't want to overcrowd the menus. Hope you like my code :) On Mon, Dec 9, 2013 at 2:51 PM, kilon alios <kilon.alios@gmail.com> wrote:
ok dont look at it, apparently it was not that either, I passed an array to a method that expected a single object so it was my bad. Sorry to bother you I will take a thorough look and test it further to make sure it works 100% . For now it looks like it copy pastes work just fine. I tried to copy paste a single method it has done so without any issues. I was thinking adding Paste new... to offer the user the option to paste the method but with a different name. Hows that sounds ?
On Mon, Dec 9, 2013 at 2:38 PM, kilon alios <kilon.alios@gmail.com> wrote:
I don't think its confusing , what I am doing is store self selectedMethods to methodsToBeCopied instance variable. I choose this approach for when you dont remember the name of the class or why do that extra dialog step when you can just simple paste it ?
I see an issue with my code though I think it may cause a problem if I open another instance of nautilus window then that instance variable value wont exist for that instance so apparently I am doing it wrong and I will need to move this to class side. Maybe thats the reason for DNU.
Dont worry I am not in a hurry, apparently I need to look into this. Sorry for that, I am not a very good coder :(
On Mon, Dec 9, 2013 at 2:29 PM, Benjamin < Benjamin.VanRyseghem.Pharo@gmail.com> wrote:
The copy/paste mechanism is always a bit confusing since you often do not know what is in the clipboard (even if people are use to it, I often see people copying a line, then retype it because they forgot it was here etc)
Why not a âmoveâ like popup where you choose directly the destination ?
For your bug, I cannot have a look right now, but I will asap
Ben
On 09 Dec 2013, at 10:57, kilon alios <kilon.alios@gmail.com> wrote:
ok I figured some things out and created the relevant methods but I am getting a MNU with copyMethod: toTheClass:
Array(Object)>>doesNotUnderstand: #realClass PackageTreeNautilusUI(AbstractNautilusUI)>>copyMethod:toTheClass: PackageTreeNautilusUI(NautilusUI)>>pasteMethod MethodWidget class>>elementsMenu: in Block: [ target pasteMethod ] BlockClosure>>cull: ToggleMenuItemMorph(MenuItemMorph)>>invokeWithEvent: in Block: [ ... BlockClosure>>ensure: CursorWithMask(Cursor)>>showWhile: ToggleMenuItemMorph(MenuItemMorph)>>invokeWithEvent: ToggleMenuItemMorph(MenuItemMorph)>>mouseUp: ToggleMenuItemMorph(MenuItemMorph)>>handleMouseUp: MouseButtonEvent>>sentTo: ToggleMenuItemMorph(Morph)>>handleEvent: MorphicEventDispatcher>>dispatchDefault:with: MorphicEventDispatcher>>dispatchEvent:with: ToggleMenuItemMorph(Morph)>>processEvent:using: MorphicEventDispatcher>>dispatchDefault:with: MorphicEventDispatcher>>dispatchEvent:with: MenuMorph(Morph)>>processEvent:using: MenuMorph(Morph)>>processEvent: MenuMorph>>handleFocusEvent: HandMorph>>sendFocusEvent:to:clear: in Block: [ ... BlockClosure>>on:do: WorldMorph(PasteUpMorph)>>becomeActiveDuring: HandMorph>>sendFocusEvent:to:clear: HandMorph>>sendEvent:focus:clear: HandMorph>>sendMouseEvent: HandMorph>>handleEvent: HandMorph>>processEvents WorldState>>doOneCycleNowFor: in Block: [ :h | ...
you can find my code here
http://www.smalltalkhub.com/#!/~kilon/copyMethod/
Am I doing something wrong ?
Just for your information I added 2 menu entries and 2 corresponding methods , one for Copy and one for Paste.
On Sun, Dec 8, 2013 at 12:27 AM, Benjamin < Benjamin.VanRyseghem.Pharo@gmail.com> wrote:
The menus are on AbstractNautilusUI class, protocol âmenusâ
You can find how to move methods in AbstractTool. I guess the copy will be there too :)
Ben
On 07 Dec 2013, at 23:16, kilon alios <kilon.alios@gmail.com> wrote:
Check Mate in 2 moves. Well played my friend, well played.
:P
Ok I will bite , how I figure out the right click menu and the copy function ? Which classes and methods should I look at ? Help me understand and Santa Clause will bring the slice down your chimney.
On Sun, Dec 8, 2013 at 12:11 AM, Benjamin < Benjamin.VanRyseghem.Pharo@gmail.com> wrote:
Was not plan, but if someone propose a slice, it will get in :P
Ben
On 07 Dec 2013, at 22:53, kilon alios <kilon.alios@gmail.com> wrote:
thanks. Is there any chance this will make it into the right click menu ? Looks like quite essential to me. Also it would make it unnecessary to open a new nautilus window for the shake of copying to an another package.
On Sat, Dec 7, 2013 at 11:26 PM, Benjamin < Benjamin.VanRyseghem.Pharo@gmail.com> wrote:
drag and drop them holding shift (you should see a little red â+â)
Ben
On 07 Dec 2013, at 22:15, kilon alios <kilon.alios@gmail.com> wrote:
Hey there I was wondering how to copy a couple of methods I have from one class to another. I can't find anything that can do this from right clicking the method.