기본 콘텐츠로 건너뛰기

라벨이 drag and drop인 게시물 표시

Rx 에서 drag and drop 구현.

http://jsbin.com/geqige/edit?js,console,output 선 소스. ( 조금 더 자세한 구현 :  http://jsbin.com/ziraga/edit?html,js,output ) 먼저 Drag and Drop이라는게 어떤 절차인지 생각해보면 이동하고자 하는 대상에 MouseDown 이동하고자 하는 지점까지 MouseMove 이동하고자 하는 지점에서 MouseUp 하는 세개의 동작을 순서대로 실행하는 것이라 할 수 있겠다. 100,100 위치에 있는 A라는 대상을 200,200까지 Drag and Drop을 하는 과정을 표로 옮기면 시간(seq) 행동 좌표 1 mousedown (150,150) 2 mousemove (150,150) 3 mousemove (160,160) 4 mousemove (170,170) 5 mousemove (..., ...) (n-1)th mousemove (250, 250) (n)th mouseup (250, 250) 과 같은 과정을 수행할 것이다. 눈치챘을지도 모르겠지만 mousemove 구간이 바로 Stream이다! Rx 기준으로 그러면 다시 Drag and Drop을 재정의하면 mousedown 이후 시점으로부터 mouseup이 되기전까지 mousemove 를 Observe 하는 것 인것이다. 그러면 재료를 모아보자. mousedown mouseup mousemove 이 세 개를 Observable 로 만들자.   const down$ = Rx.Observable.fromEvent(box, 'mousedown');   const...

XCode OS X Application : Drag & Drop 후 파일 처리

개인적으로 필요한 유틸이 있어서 appleScript 로 만들까하다가 XCode 4.4 로 OS X Application 을 만들어 본 적이 없어서 Drag & Drop, Pipe, File 처리 같은 걸 해봤다. xib 에 드래그할 대상인 NSImageView 를 놓고 그 NSImageView 를 Customize 한 NSCImageView 를 만들어서 구현했다. performDragOperation 이벤트에서  NSPasteboard  *paste = [sender draggingPasteboard]; 로 NSPasteboard 객체에 드래그 한 것들을 가지고 NSFilenamesPboardType 인것들을 타입으로 추출하여 NSData로 받았다. NSArray *fileArray = [paste propertyListForType : @"NSFilenamesPboardType" ]; 파일 목록은 propertyListForType으로 string array 를 받을 수 있다. http://borkware.com/quickies/one?topic=nstask shell 실행하고 결과 stdout 을 받는 것 처리하는데 위의 링크를 참조했다.   NSTask *task = [[ NSTask   alloc ]  init ];   [task  setLaunchPath : @" <SHELL COMMAND> " ]; NSTask 를 setLaunchPath 메서드를 사용하여 콜할 커맨드를 지정하고   [task  setArguments :[ NSArray   arrayWithObjects : <@args> , file,  nil ]]; N개의 argument 를 지정   NS...