[API] Allow null to be passed as the shortcut param to MenuItem (#35)
Co-authored-by: SpaiR <klimbetoo@gmail.com>
This commit is contained in:
1 parent
8af31fd32c
commit
04b7c4e4fe
1 file changed
+42
-11
@@ -4010,23 +4010,23 @@ public class ImGui {
|
|||||||
/**
|
/**
|
||||||
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||||
*/
|
*/
|
||||||
public static native boolean menuItem(String label, String shortcut); /*
|
public static boolean menuItem(String label, String shortcut) {
|
||||||
return ImGui::MenuItem(label, shortcut);
|
return nMenuItem(label, shortcut, false, true);
|
||||||
*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||||
*/
|
*/
|
||||||
public static native boolean menuItem(String label, String shortcut, boolean selected); /*
|
public static boolean menuItem(String label, String shortcut, boolean selected) {
|
||||||
return ImGui::MenuItem(label, shortcut, selected);
|
return nMenuItem(label, shortcut, selected, true);
|
||||||
*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
* Return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||||
*/
|
*/
|
||||||
public static native boolean menuItem(String label, String shortcut, boolean selected, boolean enabled); /*
|
public static boolean menuItem(String label, String shortcut, boolean selected, boolean enabled) {
|
||||||
return ImGui::MenuItem(label, shortcut, selected, enabled);
|
return nMenuItem(label, shortcut, selected, enabled);
|
||||||
*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when activated + toggle (*pSelected) if pSelected != NULL
|
* Return true when activated + toggle (*pSelected) if pSelected != NULL
|
||||||
@@ -4042,11 +4042,42 @@ public class ImGui {
|
|||||||
return nMenuItem(label, shortcut, pSelected.getData(), enabled);
|
return nMenuItem(label, shortcut, pSelected.getData(), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true when activated
|
||||||
|
*/
|
||||||
|
private static native boolean nMenuItem(String labelObj, String shortcutObj, boolean selected, boolean enabled); /*MANUAL
|
||||||
|
char* label = (char*)env->GetStringUTFChars(labelObj, JNI_FALSE);
|
||||||
|
char* shortcut = NULL;
|
||||||
|
if (shortcutObj != NULL)
|
||||||
|
shortcut = (char*)env->GetStringUTFChars(shortcutObj, JNI_FALSE);
|
||||||
|
|
||||||
|
jboolean result = ImGui::MenuItem(label, shortcut, selected, enabled);
|
||||||
|
|
||||||
|
if (shortcutObj != NULL)
|
||||||
|
env->ReleaseStringUTFChars(shortcutObj, shortcut);
|
||||||
|
env->ReleaseStringUTFChars(labelObj, label);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true when activated + toggle (*pSelected) if pSelected != NULL
|
* Return true when activated + toggle (*pSelected) if pSelected != NULL
|
||||||
*/
|
*/
|
||||||
private static native boolean nMenuItem(String label, String shortcut, boolean[] pSelected, boolean enabled); /*
|
private static native boolean nMenuItem(String labelObj, String shortcutObj, boolean[] pSelectedObj, boolean enabled); /*MANUAL
|
||||||
return ImGui::MenuItem(label, shortcut, &pSelected[0], enabled);
|
char* label = (char*)env->GetStringUTFChars(labelObj, JNI_FALSE);
|
||||||
|
char* shortcut = NULL;
|
||||||
|
if (shortcutObj != NULL)
|
||||||
|
shortcut = (char*)env->GetStringUTFChars(shortcutObj, JNI_FALSE);
|
||||||
|
bool* pSelected = (bool*)env->GetPrimitiveArrayCritical(pSelectedObj, JNI_FALSE);
|
||||||
|
|
||||||
|
jboolean result = ImGui::MenuItem(label, shortcut, &pSelected[0], enabled);
|
||||||
|
|
||||||
|
env->ReleasePrimitiveArrayCritical(pSelectedObj, pSelected, 0);
|
||||||
|
if (shortcutObj != NULL)
|
||||||
|
env->ReleaseStringUTFChars(shortcutObj, shortcut);
|
||||||
|
env->ReleaseStringUTFChars(labelObj, label);
|
||||||
|
|
||||||
|
return result;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
|
|||||||
Reference in new issue
Block a user