Page 1 sur 1

Positionement caret dans canvas gadget

Publié : jeu. 12/juin/2014 7:17
par microdevweb
Bonjour,

Comment fait on pour positionner le caret / saisie clavier dans un canvas gadget

Merci d'avance

Re: Positionement caret dans canvas gadget

Publié : jeu. 12/juin/2014 10:45
par Mesa
Je crois qu'on ne peut pas sans utiliser les api.

Sous Windows, ça donnerait quelque chose comme ça :

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 10, 10, 200, 200)
  
  
  EdWin= GetActiveWindow()
  CarH=12
  CreateCaret_(WindowID(EdWin),0,1,CarH) ; Create a cursor...
  SetCaretPos_(100,100)
  ShowCaret_(WindowID(EdWin))
  
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Gadget And EventGadget() = 0 
      If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
        If StartDrawing(CanvasOutput(0))
          x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
          y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
          Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
          StopDrawing()
        EndIf
      EndIf
    EndIf    
    
  Until Event = #PB_Event_CloseWindow
EndIf

;http://msdn.microsoft.com/en-us/library/windows/desktop/ms648405%28v=vs.85%29.aspx
;Getcaretpos() : http://msdn.microsoft.com/en-us/library/windows/desktop/ms648402%28v=vs.85%29.aspx
;DestroyCaret_()
;HideCaret()
Mesa.

Re: Positionement caret dans canvas gadget

Publié : jeu. 12/juin/2014 11:14
par microdevweb
Merci mesa,

Je pense également que sans les Api ce ne soit possible, (ou en le programmant graphiquement peut-être ce qui risque de man ger beaucoup de ressource).

Je teste merci encore