2 * Copyright 2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include "EditWindow.h"
15 #include <LayoutBuilder.h>
16 #include <TextControl.h>
18 #include <StringView.h>
20 #include "ShortcutsWindow.h"
23 EditWindow::EditWindow(const char* placeholder
, uint32 flags
)
25 BWindow(BRect(0, 0, 0, 0), "", B_MODAL_WINDOW
, flags
)
27 fTextControl
= new BTextControl("", placeholder
, NULL
);
29 BButton
* okButton
= new BButton("Ok", new BMessage(B_CONTROL_MODIFIED
));
30 okButton
->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT
, B_ALIGN_TOP
));
31 SetDefaultButton(okButton
);
33 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
34 .SetInsets(B_USE_WINDOW_INSETS
)
41 EditWindow::MessageReceived(BMessage
* message
)
43 switch (message
->what
) {
44 case B_CONTROL_MODIFIED
:
48 BWindow::MessageReceived(message
);
57 fSem
= create_sem(0, "EditSem");
63 BSize psize
= GetLayout()->PreferredSize();
64 ResizeTo(max_c(be_plain_font
->StringWidth(fTextControl
->Text()) * 1.5,
71 BString result
= fTextControl
->Text();