PureBoard
http://forums.purebasic.com/german/

BlockUI
http://forums.purebasic.com/german/viewtopic.php?f=33&t=31689
Seite 1 von 1

Autor:  Kiffi [ 18.10.2019 17:11 ]
Betreff des Beitrags:  BlockUI

Salü,

wenn Ihr Eure Benutzeroberfläche (oder Teile davon) blockieren wollt (weil ein lang laufender Hintergrundprozess wie HttpRequest oder ähnliches ausgeführt werden soll), könnt Ihr den $.blockUI() - Befehl verwenden.

Hiermit kann entweder der gesamte Screen, ein Fenster oder ein Gadget gesperrt werden.

Hier ist ein Beispielcode, wie man ihn benutzt:

Code:
Procedure BlockUI(Message.s)
  ! $.blockUI({ message: v_message });
EndProcedure

Procedure UnblockUI()
  ! $.unblockUI();
EndProcedure

Procedure BlockWindow(Window, Message.s)
 
  If IsWindow(Window)
    Protected WID = WindowID(Window)
    ! $(v_wid.content.parentElement.parentElement).block({ message: v_message });
  EndIf
 
EndProcedure

Procedure UnblockWindow(Window)
 
  If IsWindow(Window)
    Protected WID = WindowID(Window)
    ! $(v_wid.content.parentElement.parentElement).unblock();
  EndIf
 
EndProcedure

Procedure BlockGadget(Gadget, Message.s)
 
  If IsGadget(Gadget)
    Protected GID = GadgetID(Gadget)
    ! $(v_gid.div).block({ message: v_message });
  EndIf
 
EndProcedure

Procedure UnblockGadget(Gadget)
 
  If IsGadget(Gadget)
    Protected GID = GadgetID(Gadget)
    ! $(v_gid.div).unblock();
  EndIf
 
EndProcedure

; Demo

CompilerIf #PB_Compiler_IsMainFile
 
  Enumeration
    #Window
    #btnBlockScreen
    #btnBlockWindow
    #btnBlockGadget
    #Gadget
  EndEnumeration
 
  Enumeration
    #timBlock
  EndEnumeration
 
  Global BlockType.s
 
  Procedure timBlockEvent()
   
    Select BlockType
       
      Case "Screen"
        UnblockUI()
       
      Case "Window"
        UnblockWindow(#Window)
       
      Case "Gadget"
        UnblockGadget(#Gadget)
       
    EndSelect
   
    RemoveWindowTimer(#Window, #timBlock)
   
    DisableGadget(#btnBlockScreen, #False)
    DisableGadget(#btnBlockWindow, #False)
    DisableGadget(#btnBlockGadget, #False)
   
  EndProcedure
 
  Procedure BlockIt()
   
    Select BlockType
       
      Case "Screen"
        BlockUI("<h1>Waiting 2 seconds....</h1>")
       
      Case "Window"
        BlockWindow(#Window, "<h2>Waiting 2 seconds....</h2>")
       
      Case "Gadget"
        BlockGadget(#Gadget, "<h3>Waiting 2 seconds....</h3>")
       
    EndSelect
   
    AddWindowTimer(#Window, #timBlock, 2000)
    BindEvent(#PB_Event_Timer, @timBlockEvent(), #Window, #timBlock)
   
    DisableGadget(#btnBlockScreen, #True)
    DisableGadget(#btnBlockWindow, #True)
    DisableGadget(#btnBlockGadget, #True)
   
  EndProcedure
 
  ; --
 
  Procedure btnBlockScreenEvent()
    BlockType = "Screen"
    BlockIt()
  EndProcedure
 
  Procedure btnBlockWindowEvent()
    BlockType = "Window"
    BlockIt()
  EndProcedure
 
  Procedure btnBlockGadgetEvent()
    BlockType = "Gadget"
    BlockIt()
  EndProcedure
 
  ; --
 
  OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 420, 400, "BlockUI-Demo", #PB_Window_ScreenCentered)
 
  ButtonGadget(#btnBlockScreen, 10,  10, 400, 50, "Block screen")
  ButtonGadget(#btnBlockWindow, 10,  70, 400, 50, "Block window")
  ButtonGadget(#btnBlockGadget, 10, 130, 400, 50, "Block gadget")
 
  ListIconGadget(#Gadget, 10, 190, 400, 200, "Col1", 100, #PB_ListIcon_GridLines)
  AddGadgetColumn(#Gadget, 1, "Col2", 100)
 
  AddGadgetItem(#Gadget, -1, "Foo" + #LF$ + "Bar")
 
  BindGadgetEvent(#btnBlockScreen, @btnBlockScreenEvent())
  BindGadgetEvent(#btnBlockWindow, @btnBlockWindowEvent())
  BindGadgetEvent(#btnBlockGadget, @btnBlockGadgetEvent())
 
CompilerEndIf


Weitere Informationen gibt es hier: http://malsup.com/jquery/block/

Grüße ... Peter

Autor:  RSBasic [ 18.10.2019 20:16 ]
Betreff des Beitrags:  Re: BlockUI

Cool, danke fürs Teilen. :allright:

Autor:  dige [ 21.10.2019 14:54 ]
Betreff des Beitrags:  Re: BlockUI

Danke, kann man gut gebrauchen :allright:

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/