How do I improve the keyboard response for this code ?
Posted: Thu Oct 30, 2008 1:49 pm
It's a kind of HTML editor, just type html and hit CTRL-S and CTRL-E to switch between edit and html view.
As you can see, you need to press 2 or 3 times to make the program respond, I tried delays at different spots, removed them as they didn't improve response at all.
Also, there's a difference between the EDIT and HTML screens, the HTML screen has (with little input disabled) vertical scrollbar, as the EDIT window has not. Hot to add the Vscrollbar for the EDIT window ?
Cheers.
Code: Select all
If OpenWindow(0, 0, 0, 600, 300, "CTRL-S for SHOW - CTRL-E for EDIT", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
WebGadget(0, 0, 0, 600, 300, "")
HideGadget(0,1)
StringGadget(1,0,0,600,300,"",#PB_String_BorderLess | #ES_MULTILINE | #ES_AUTOHSCROLL | #ES_AUTOVSCROLL | #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT)
SetActiveGadget(1)
If LoadFont(1,"MS Sans Serif",12)
SetGadgetFont(1, FontID(1))
EndIf
AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_S, 1)
AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_E, 2)
Repeat
If WaitWindowEvent()= #PB_Event_Menu
If EventMenu()=1
HideGadget(1,1)
HideGadget(0,0)
SetActiveGadget(0)
text$=GetGadgetText(1)
new$="<html><body topmargin=0 leftmargin=0><font face='MS Sans Serif' size=3pc>"
new$ + ReplaceString(text$,Chr(13)+Chr(10),"<br>")
SetGadgetItemText(0,#PB_Web_HtmlCode,new$)
EndIf
If EventMenu()=2
HideGadget(1,0)
HideGadget(0,1)
SetActiveGadget(1)
EndIf
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf : EndAlso, there's a difference between the EDIT and HTML screens, the HTML screen has (with little input disabled) vertical scrollbar, as the EDIT window has not. Hot to add the Vscrollbar for the EDIT window ?
Cheers.