Skip to content

Commit 4c3768d

Browse files
author
Roger Lee Whitcomb
committed
Code cleanup: Request focus on the window content in ScriptApplication to
eliminate the need to click on the window to begin interacting with it. Add batch files to set the classpath to include the "lib" and "wtk/lib" directories, to allow testing, and another to restore it to the previous state. Adjust "script.bat" to call these if the original "java" invocation results in an error (presumably because the main class can't be loaded). git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1797271 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9ab7458 commit 4c3768d

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

script.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ if "%1" == "" (
33
echo Usage: %0 path_to_bxml_file
44
exit /b 1
55
)
6-
java org.apache.pivot.wtk.ScriptApplication "--src=%1"
6+
java org.apache.pivot.wtk.ScriptApplication "--src=%1" 2>nul
7+
if errorlevel 1 (call setenv.bat) & (java org.apache.pivot.wtk.ScriptApplication "--src=%1") & (call unsetenv.bat)

setenv.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
set CLASSPATH_OLD=%CLASSPATH%
3+
for %%F in (%CD%\lib\pivot*.jar) do call addclass %%F
4+
for %%F in (%CD%\wtk\lib\*.jar) do call addclass %%F
5+
echo CLASSPATH=%CLASSPATH%

unsetenv.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
if not "%CLASSPATH_OLD%"=="" (set CLASSPATH=%CLASSPATH_OLD%) && (set CLASSPATH_OLD=)
3+
echo CLASSPATH=%CLASSPATH%

wtk/src/org/apache/pivot/wtk/ScriptApplication.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public void startup(Display display, Map<String, String> properties) throws Exce
9292
this.window.setContent(component);
9393
}
9494
this.window.open(display);
95+
96+
Component content = this.window.getContent();
97+
if (content != null) {
98+
content.requestFocus();
99+
}
95100
}
96101

97102
@Override

0 commit comments

Comments
 (0)