*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeInsertText(
		JNIEnv* env, jclass clazz, jint handle, jstring textString) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element && element->getType() == EGUIET_EDIT_BOX) {
			IGUIEditBox* editbox = (IGUIEditBox*) element;
			const char* text = env->GetStringUTFChars(textString, NULL);
			wchar_t content[256];
			BufferIO::DecodeUTF8(text, content);
			editbox->setText(content);
			irrenv->removeFocus(editbox);
			irrenv->setFocus(editbox->getParent());
			SEvent changeEvent;
			changeEvent.EventType = EET_GUI_EVENT;
			changeEvent.GUIEvent.Caller = editbox;
			changeEvent.GUIEvent.Element = 0;
			changeEvent.GUIEvent.EventType = EGET_EDITBOX_CHANGED;
			editbox->getParent()->OnEvent(changeEvent);
			SEvent enterEvent;
			enterEvent.EventType = EET_GUI_EVENT;
			enterEvent.GUIEvent.Caller = editbox;
			enterEvent.GUIEvent.Element = 0;
			enterEvent.GUIEvent.EventType = EGET_EDITBOX_ENTER;
			editbox->getParent()->OnEvent(enterEvent);
			env->DeleteLocalRef(textString);
		}
	}
}
 */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetComboBoxSelection(
		JNIEnv* env, jclass clazz, jint handle, jint idx) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element && element->getParent()->getType() == EGUIET_COMBO_BOX) {
			IGUIComboBox* combo = (IGUIComboBox*) (element->getParent());
			core::list<IGUIElement*> children = combo->getChildren();
			core::list<IGUIElement*>::Iterator current = children.begin();
			do {
				if ((*current)->getType() == EGUIET_LIST_BOX) {
					break;
				}
				current++;
			} while (current != children.end());
			if (current == children.end()) {
				return;
			}
			IGUIListBox* list = (IGUIListBox*) *current;
			list->setSelected(idx);
			SEvent changeEvent;
			changeEvent.EventType = EET_GUI_EVENT;
			changeEvent.GUIEvent.Caller = list;
			changeEvent.GUIEvent.Element = 0;
			changeEvent.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
			combo->OnEvent(changeEvent);
		}
	}
}
 */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection(
		JNIEnv* env, jclass clazz, jint handle, jint idx) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element) {
			IGUIWindow* window = (IGUIWindow*) (element);
			core::list<IGUIElement*> children = window->getChildren();
			core::list<IGUIElement*>::Iterator current = children.begin();
			int i = 0;
			do {
				if ((*current)->getType() == EGUIET_CHECK_BOX && i++ == idx) {
					break;
				}
				current++;
			} while (current != children.end());
			if (current == children.end()) {
				return;
			}
			IGUICheckBox* checkbox = (IGUICheckBox*) *current;
			checkbox->setChecked(true);
			SEvent e;
			e.EventType = EET_GUI_EVENT;
			e.GUIEvent.Caller = checkbox;
			e.GUIEvent.Element = 0;
			e.GUIEvent.EventType = EGET_CHECKBOX_CHANGED;
			window->OnEvent(e);
			irrenv->setFocus(window);
		}
	}
}
Exemplo n.º 4
0
/*
Function hasModalDialog() checks if we currently have a modal dialog open.
*/
bool hasModalDialog()
{
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement * focused = env->getFocus();
	while ( focused )
	{
		if ( focused->isVisible() && focused->hasType(EGUIET_MODAL_SCREEN) )
			return true;
		focused = focused->getParent();
	}
	return false;
}