Mercurial > dwindows
comparison mac/dw.m @ 989:6de00477d627
Clamp the point specified in dw_mle_set_cursor() to the range of text to avoid an exception on Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 07 May 2011 14:42:35 +0000 |
parents | 87dc0f5f96d0 |
children | 2d80b4dcff9a |
comparison
equal
deleted
inserted
replaced
988:56077b50be7e | 989:6de00477d627 |
---|---|
4379 */ | 4379 */ |
4380 void API dw_mle_set_cursor(HWND handle, int point) | 4380 void API dw_mle_set_cursor(HWND handle, int point) |
4381 { | 4381 { |
4382 NSScrollView *sv = handle; | 4382 NSScrollView *sv = handle; |
4383 DWMLE *mle = [sv documentView]; | 4383 DWMLE *mle = [sv documentView]; |
4384 NSTextStorage *ts = [mle textStorage]; | |
4385 NSMutableString *ms = [ts mutableString]; | |
4386 NSUInteger length = [ms length]; | |
4387 if(point < 0) | |
4388 point = 0; | |
4389 if(point > length) | |
4390 point = (int)length; | |
4384 [mle setSelectedRange: NSMakeRange(point,point)]; | 4391 [mle setSelectedRange: NSMakeRange(point,point)]; |
4385 } | 4392 } |
4386 | 4393 |
4387 /* | 4394 /* |
4388 * Finds text in an MLE box. | 4395 * Finds text in an MLE box. |