; Module/File: Editor_CtrlTabInsert.pb ; Function: Insert TAB w. [Ctrl][Tab] and maintained Tab-Forwarding - Linux ; Author: Omi ; Date: Oct. 09, 2017 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.4/5.6 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" g_signal_connect(*instance, detailed_signal.p-utf8, *c_handler, *data, destroy= 0, flags= 0) As "g_signal_connect_data" gtk_text_buffer_insert_at_cursor(*buffer.GtkTextBuffer, text.p-utf8, len) gtk_text_view_set_accepts_tab(*text_view.GtkTextView, accepts_tab) EndImport ; Object constants #Win_Main = 0 #But1 = 0 #Edt1 = 1 #But2 = 2 #GDK_KEY_Tab= $FF09 Global.i gEvent, gQuit ProcedureC Callback_Editor_InserTabWCtrl(*widget.GtkWidget, *event.GdkEventKey, user_data) Protected.i ModKey= *event\state & $F; (requires 'modifier keys' masked with low nibble) Protected.i KeyVal= *event\keyval Protected.i Ret = #False If *widget = GadgetID(user_data) If ModKey = #GDK_CONTROL_MASK; Control-Key Select KeyVal Case #GDK_KEY_Tab gtk_text_buffer_insert_at_cursor(gtk_text_view_get_buffer_(*widget), Chr(#PB_Key_Tab), 1) Ret= #True; no further system action EndSelect EndIf EndIf ProcedureReturn Ret EndProcedure If OpenWindow(#Win_Main, 0, 0, 400, 260, "Editor TAB handling 2", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) TextGadget(#PB_Any, 5, 5, 390, 50, "Insert TAB in EditorGadget w. [Ctrl][Tab]." + #LF$ + "Focus forwarding with [Tab] stays activ!") ButtonGadget(#But1, 15, 70, 370, 26, "focusable Button 1 (w/o function)") EditorGadget(#Edt1, 15, 100, 370, 120) ButtonGadget(#But2, 15, 220, 370, 26, "focusable Button 2 (w/o function)") SetGadgetText(#Edt1, "TAB input to Editor with [Ctrl][Tab] OR " + #LF$ + "move focus To Next widget With [Tab]!") gtk_text_view_set_accepts_tab(GadgetID(#Edt1), #False) g_signal_connect(GadgetID(#Edt1), "key-press-event", @Callback_Editor_InserTabWCtrl(), #Edt1) Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True EndSelect Until gQuit EndIf ; IDE Options = PureBasic 5.46 LTS (Linux - x86) ; CursorPosition = 20 ; Folding = - ; EnableUnicode ; EnableXP