| 2610 | } |
| 2611 | |
| 2612 | static void |
| 2613 | MenwClick(NhWindow *wind, Point pt) |
| 2614 | { |
| 2615 | Rect wrect; |
| 2616 | |
| 2617 | GetWindowBounds(wind->its_window, kWindowContentRgn, &wrect); |
| 2618 | OffsetRect(&wrect, -wrect.left, -wrect.top); |
| 2619 | if (inSelect != WIN_ERR && wind->how != PICK_NONE) { |
| 2620 | short currentRow = -1, previousRow = -1; |
| 2621 | short previousItem = -1, item = -1; |
| 2622 | Boolean majorSelectState, firstRow = TRUE; |
| 2623 | |
| 2624 | do { |
| 2625 | #if !TARGET_API_MAC_CARBON |
| 2626 | SystemTask(); |
| 2627 | #endif |
| 2628 | GetMouse(&pt); |
| 2629 | currentRow = pt.v / wind->row_height; |
| 2630 | if (pt.h < wrect.left || pt.h > wrect.right || pt.v < 0 |
| 2631 | || pt.v > wrect.bottom || currentRow >= wind->y_size) { |
| 2632 | continue; /* not in window range */ |
| 2633 | } |
| 2634 | |
| 2635 | item = ListCoordinateToItem(wind, currentRow); |
| 2636 | |
| 2637 | if (item != previousItem) { |
| 2638 | /* Implement typical Mac multiple-selection behavior |
| 2639 | * (ie, not the UI implemented by the Finder) |
| 2640 | */ |
| 2641 | Boolean itemIsSelected = (ListItemSelected(wind, item) >= 0); |
| 2642 | |
| 2643 | if (firstRow) { |
| 2644 | /* this is first valid row, so major state is opposite of |
| 2645 | * what this row is */ |
| 2646 | majorSelectState = !itemIsSelected; |
| 2647 | firstRow = FALSE; |
| 2648 | } |
| 2649 | |
| 2650 | if (wind->how == PICK_ONE && previousItem != -1) { |
| 2651 | /* if previous row was selected and we're only selecting |
| 2652 | * one object, |
| 2653 | * deselect previous row! |
| 2654 | */ |
| 2655 | ToggleMenuListItemSelected(wind, previousItem); |
| 2656 | ToggleMenuSelect(wind, previousRow); |
| 2657 | previousItem = -1; |
| 2658 | } |
| 2659 | |
| 2660 | if (item == -1) |
| 2661 | continue; /* header line */ |
| 2662 | |
| 2663 | if (majorSelectState != itemIsSelected) { |
| 2664 | ToggleMenuListItemSelected(wind, item); |
| 2665 | ToggleMenuSelect(wind, currentRow); |
| 2666 | } |
| 2667 | |
| 2668 | previousRow = currentRow; |
| 2669 | previousItem = item; |
no test coverage detected