From f4a6554fd05883202e7238956a2f4dc5d4d800f0 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 21 Aug 2006 23:42:29 +0000 Subject: [PATCH] Allow a custom chat button to be added to the generic chat view. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@26 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/jme/chat/ChatView.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/java/com/threerings/jme/chat/ChatView.java b/src/java/com/threerings/jme/chat/ChatView.java index 6a6a4be8..737da328 100644 --- a/src/java/com/threerings/jme/chat/ChatView.java +++ b/src/java/com/threerings/jme/chat/ChatView.java @@ -23,14 +23,16 @@ package com.threerings.jme.chat; import java.util.StringTokenizer; +import com.jme.renderer.ColorRGBA; + +import com.jmex.bui.BButton; import com.jmex.bui.BContainer; import com.jmex.bui.BTextArea; import com.jmex.bui.BTextField; import com.jmex.bui.event.ActionEvent; import com.jmex.bui.event.ActionListener; import com.jmex.bui.layout.BorderLayout; - -import com.jme.renderer.ColorRGBA; +import com.jmex.bui.layout.GroupLayout; import com.threerings.util.Name; @@ -57,15 +59,10 @@ public class ChatView extends BContainer _chatdtr = chatdtr; setLayoutManager(new BorderLayout(2, 2)); add(_text = new BTextArea(), BorderLayout.CENTER); - add(_input = new BTextField(), BorderLayout.SOUTH); - - _input.addListener(new ActionListener() { - public void actionPerformed (ActionEvent event) { - if (handleInput(_input.getText())) { - _input.setText(""); - } - } - }); + _incont = new BContainer(GroupLayout.makeHStretch()); + add(_incont, BorderLayout.SOUTH); + _incont.add(_input = new BTextField()); + _input.addListener(_inlist); } public void willEnterPlace (PlaceObject plobj) @@ -94,6 +91,12 @@ public class ChatView extends BContainer } } + public void setChatButton (BButton button) + { + _incont.add(button, GroupLayout.FIXED); + button.addListener(_inlist); + } + /** * Instructs our chat input field to request focus. */ @@ -174,8 +177,18 @@ public class ChatView extends BContainer } } + /** Used to trigger sending chat (on return key or button press). */ + protected ActionListener _inlist = new ActionListener() { + public void actionPerformed (ActionEvent event) { + if (handleInput(_input.getText())) { + _input.setText(""); + } + } + }; + protected ChatDirector _chatdtr; protected SpeakService _spsvc; protected BTextArea _text; + protected BContainer _incont; protected BTextField _input; }