@@ -283,42 +283,37 @@ final class DataGridCellView: NSView {
283283 }
284284
285285 private func computeAccessoryRect( ) -> NSRect {
286- switch kind {
287- case . text:
288- return . zero
289- case . foreignKey:
286+ if kind == . foreignKey {
290287 guard let raw = rawValue, !raw. isEmpty else { return . zero }
291288 let size = NSSize ( width: 16 , height: 16 )
292289 let x = bounds. maxX - DataGridMetrics. cellHorizontalInset - size. width
293290 let y = ( bounds. height - size. height) / 2
294291 return NSRect ( x: x, y: y, width: size. width, height: size. height)
295- case . dropdown, . boolean, . json, . blob, . date:
296- guard isEditableCell else { return . zero }
297- let size = NSSize ( width: 12 , height: 14 )
298- let minRequired = size. width + 2 * DataGridMetrics. cellHorizontalInset
299- guard bounds. width >= minRequired else { return . zero }
300- let x = bounds. maxX - DataGridMetrics. cellHorizontalInset - size. width
301- let y = ( bounds. height - size. height) / 2
302- return NSRect ( x: x, y: y, width: size. width, height: size. height)
303292 }
293+ guard kind. showsChevron, isEditableCell else { return . zero }
294+ let size = NSSize ( width: 12 , height: 14 )
295+ let minRequired = size. width + 2 * DataGridMetrics. cellHorizontalInset
296+ guard bounds. width >= minRequired else { return . zero }
297+ let x = bounds. maxX - DataGridMetrics. cellHorizontalInset - size. width
298+ let y = ( bounds. height - size. height) / 2
299+ return NSRect ( x: x, y: y, width: size. width, height: size. height)
304300 }
305301
306302 private func drawAccessory( in rect: NSRect ) {
307303 guard !rect. isEmpty else { return }
308304 let image : CGImage ?
309- switch kind {
310- case . text:
311- return
312- case . foreignKey:
305+ if kind == . foreignKey {
313306 image = onEmphasizedSelection ? Self . fkArrowEmphasized : Self . fkArrowNormal
314- case . dropdown , . boolean , . json , . blob , . date :
307+ } else if kind . showsChevron {
315308 if visualState. isDeleted {
316309 image = Self . chevronDisabled
317310 } else if onEmphasizedSelection {
318311 image = Self . chevronEmphasized
319312 } else {
320313 image = Self . chevronNormal
321314 }
315+ } else {
316+ return
322317 }
323318 guard let cgImage = image, let context = NSGraphicsContext . current? . cgContext else { return }
324319 context. saveGState ( )
@@ -337,21 +332,17 @@ final class DataGridCellView: NSView {
337332
338333 override func mouseDown( with event: NSEvent ) {
339334 let point = convert ( event. locationInWindow, from: nil )
340- if !accessoryHitRect. isEmpty && accessoryHitRect. contains ( point) {
341- switch kind {
342- case . foreignKey:
343- accessoryDelegate? . dataGridCellDidClickFKArrow ( row: cellRow, columnIndex: cellColumnIndex)
344- return
345- case . dropdown, . boolean, . json, . blob, . date:
346- guard !visualState. isDeleted else {
347- super. mouseDown ( with: event)
348- return
349- }
350- accessoryDelegate? . dataGridCellDidClickChevron ( row: cellRow, columnIndex: cellColumnIndex)
351- return
352- case . text:
353- break
354- }
335+ guard !accessoryHitRect. isEmpty, accessoryHitRect. contains ( point) else {
336+ super. mouseDown ( with: event)
337+ return
338+ }
339+ if kind == . foreignKey {
340+ accessoryDelegate? . dataGridCellDidClickFKArrow ( row: cellRow, columnIndex: cellColumnIndex)
341+ return
342+ }
343+ if kind. showsChevron, !visualState. isDeleted {
344+ accessoryDelegate? . dataGridCellDidClickChevron ( row: cellRow, columnIndex: cellColumnIndex)
345+ return
355346 }
356347 super. mouseDown ( with: event)
357348 }
0 commit comments