From 089186a88ce28f59062df35d00b51572133382a1 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 7 May 2015 00:31:31 -0400 Subject: [PATCH] Implemented read-only uiEntries on OS X. --- darwin/entry.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/darwin/entry.m b/darwin/entry.m index a748e2c0..4f79954e 100644 --- a/darwin/entry.m +++ b/darwin/entry.m @@ -72,6 +72,23 @@ static void entryOnChanged(uiEntry *ee, void (*f)(uiEntry *, void *), void *data [e->delegate setOnChanged:f data:data]; } +static int entryReadOnly(uiEntry *ee) +{ + struct entry *e = (struct entry *) ee; + + return [e->textfield isEditable] == NO; +} + +static void entrySetReadOnly(uiEntry *ee, int readonly) +{ + struct entry *e = (struct entry *) ee; + BOOL editable; + + editable = YES; + if (readonly) + editable = NO; + [e->textfield setEditable:editable]; +} // these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/ void finishNewTextField(NSTextField *t, BOOL isEntry) @@ -110,6 +127,8 @@ uiEntry *uiNewEntry(void) uiEntry(e)->Text = entryText; uiEntry(e)->SetText = entrySetText; uiEntry(e)->OnChanged = entryOnChanged; + uiEntry(e)->ReadOnly = entryReadOnly; + uiEntry(e)->SetReadOnly = entrySetReadOnly; return uiEntry(e); }