[Cocoa] NSOutlineView 에서 텍스트 편집하기

NSOutlineView를 사용하여 트리형식으로 정보를 표현할 때

해당 row를 더블클릭하거나 context menu를 통해 해당 row의

텍스트를 변경하고 싶을 때가 있다. 새로운 창을 띄우거나 팝업을 띄워서

처리한다면 직관적이지 않기때문에 NSOutlineView내에서 처리하는게 좋다.

 

 

context menu나 버튼이벤트를 통해서 선택된 row가 에디트 모드로 변경되게 하고 싶다면

아래와 같이 outlineview의 editColumn을 사용한다.

- (IBAction)editOutlineViewTextAction:(id)sender
{
    NSInteger rowIndex = [mOutlineView selectedRow];

    if (rowIndex > -1)
    {
        [mOutlineView editColumn:0 row:rowIndex withEvent:nil select:YES];
    }
}

 

해당 row가 편집모드가 되었다면 사용자 입력을 받고 리턴키를 치거나 row에서

포커스가 빠지면서 편집 완료가 될 경우 해당 이벤트를 받아서 변경된 값으로 저장해주어야 한다.

그럴땐 NSControl의 delegate함수인 controlTextDidEndEditing을 사용한다.

 

- (void)controlTextDidEndEditing:(NSNotification *)obj
{
    NSString *newName = [[[obj userInfo] objectForKey:@"NSFieldEditor"] string];
}


, ,

No Comments

Bruno Mars – It Will Rain

It Will Rain by Bruno Mars on Grooveshark
 

If you ever leave me baby,

Leave some morphine at my door

‘Cause it would take a whole lot of medication

To realize what we used to have,

We don’t have it anymore.



There’s no religion that could save me

No matter how long my knees are on the floor

So keep in mind all the sacrifices I’m makin’

Will keep you by my side

Will keep you from walkin’ out the door.



[Chorus]

Cause there’ll be no sunlight

If I lose you, baby

There’ll be no clear skies

If I lose you, baby

Just like the clouds

My eyes will do the same, if you walk away

Everyday it will rain, rain, rain…



I’ll never be your mother’s favorite

Your daddy can’t even look me in the eye

Oooh if I was in their shoes, I’d be doing the same thing

Sayin there goes my little girl

Walkin’ with that troublesome guy



But they’re just afraid of something they can’t understand

Oooh well little darlin’ watch me change their minds

Yeah for you I’ll try I’ll try I’ll try I’ll try

I’ll pick up these broken pieces ’til I’m bleeding

If that’ll make you mine



[Chorus]

Cause there’ll be no sunlight

If I lose you, baby

There’ll be no clear skies

If I lose you, baby

Just like the clouds

My eyes will do the same if you walk away

Everyday it will rain, rain, rain…



[Bridge]

Don’t just say, goodbye

Don’t just say, goodbye

I’ll pick up these broken pieces ’til I’m bleeding

If that’ll make it right



[Chorus]

Cause there’ll be no sunlight

If I lose you, baby

There’ll be no clear skies

If I lose you, baby

Just like the clouds

My eyes will do the same if you walk away

Everyday it will rain, rain, rain…



,

No Comments

[Cocoa] IKImageBrowserView에서 그룹으로 표시하기

IKImageBrowserView를 사용하면 일반 Thumbnail View를 손쉽게 만들 수 있다.

Thumbnail view를 만드는 방법은 다음 링크에서 알아보면 된다. 예제

그런데 아래 그림과 같은 그룹으로 표시하기 위해선 몇가지 작업이 더 필요하다.

IKImageBrowserView에 다음과 같은 Delegate 함수들이 존재한다.

 

- (NSUInteger)numberOfGroupsInImageBrowser:(IKImageBrowserView *) aBrowser

이 함수에서 그룹의 갯수를 리턴해주면 된다.

 

 

- (NSDictionary *)imageBrowser:(IKImageBrowserView *) aBrowser groupAtIndex:(NSUInteger) index

이 함수에서 그룹의 Range를 설정한 NSDictionary 를 리턴해주면 IKImageBrowserView가 알아서 그룹으로 표시해준다.

 

return [NSDictionary dictionaryWithObjectsAndKeys:

            [NSValue valueWithRange:NSMakeRange(0, 10)], IKIMageBrowserGroupRangeKey, nil];

 

Range 계산만 잘 해주면 아주 간단하게 위와 같은 화면을 만들어 낼 수 있다.



, ,

2 Comments

고인의 명복을 빕니다.



No Comments

허전하지요, 산다는게

 

허전하지요, 산다는게

                                            – 정성수

 

혼자서 쓸쓸하고 둘이서 쓸쓸하고

만나서 허전하고 헤어져서 허전하고

 

가을에서 다시 가을이 올 때까지

쓸쓸해서 혼자 마시고

사랑조차 쓸쓸해서 다시는 사랑하지 않고

 

질긴 외로움의 뿌리 하나로

저 시끄러운 세상을 바라보며

쓸쓸하게 웃지요

 

바람 속에 서 있는 한 그루의 대나무처럼

오늘도 시퍼렇게 살아남아서…



No Comments